title: How to login into router with default credentials using python
body: <p>I have TP Link router (WR841N).I want to login into my TP link router and needs to change primary and secondary DNSusing script.</p>
  
  <p>I tried to login using below script but not succeeded:</p>
  
  <pre><code>import urllib2
  import urllib
  import cookielib
  
  def main():
      userName = 'admin'
      pcPassword = 'admin'
      cj = cookielib.CookieJar()
      opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
      login_data = urllib.urlencode({'userName' : userName, 'pcPassword' : pcPassword})
      resp = opener.open('http://192.168.0.1/userRpm/LoginRpm.htm', login_data)
      print(resp.read())
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>And then how to change primary and secondary dns using script.</p>