问题
I am trying to write a script that'll let me interact with my router without opening up the browser. I wrote the following script.
from bs4 import BeautifulSoup
import requests
username = input("Enter username ")
password = input("Enter Password ")
with requests.Session() as c:
url = "http://192.168.1.2" #+url make it dynamic later
print(url)
username = username
password = password
r = c.get(url)
print(r)
login_data = dict(userName=username, pcPassword=password,next='/')
c.post(url,data=login_data, headers={"Referer": "http://www.techruse.com/"})
page = c.get('http://192.168.1.2//userRpm/WlanStationRpm.htm')
print(page.content)
every time I run the code and enter my correct password this is the response I get.
<Response [200]>
b'<body><script language="javaScript">window.parent.document.cookie="Authorization=;path=/";\nwindow.parent.location.href = "http://192.168.1.2";\n</script></body></html>\n'
and with the wrong password the response is exactly the same. I understand that code means The request was full filled (source : https://www.w3.org/Protocols/HTTP/HTRESP.html) either I have the wrong understanding of the term or maybe I am not authenticating at all. Can someone please explain this to me? thank you.
来源:https://stackoverflow.com/questions/43451135/ok-response-even-with-the-wrong-password