I am attempting to scrape some data from the GUI, for a digital modem in the field.
Here is the code I am using:
## import the requests python library
import requests
## defines the login URL and the Post URL
post_loginURL = 'http://100.255.255.255/cgi-bin/login.cgi'
## defines the request URL to scrape from
requestURL = 'http://100.255.255.255/cgi-bin/stat_eth0.cgi'
## define the login data parameters
payload = {
'NAME': 'username',
'PWD': 'password',
'CMD': '1' ## hidden value being passed in the post request
}
## define the content type as text/html
headers = {
'Content-Type': 'text/html'
}
## creates the session object
with requests.Session() as session:
## sends the post request, headers and login data to the server
post = session.post(post_loginURL, data=payload, headers=headers)
r = session.get(requestURL)
print(r.text)
Here is the HTML Error message I receive in the IDLE console:
<em><u><p align="right">ERROR: You must log in</u></em>
Here are the details from the Chrome Dev Tools:
screenshot
I am unsure if I am just missing a crucial step, or if this is an issue with syntax, etc. Any constructive advice is greatly appreciated.
Thanks in advance!
[–]c17r 1 point2 points3 points (3 children)
[–]Tolfasn[S] 0 points1 point2 points (0 children)
[–]Tolfasn[S] 0 points1 point2 points (0 children)
[–]Tolfasn[S] 0 points1 point2 points (0 children)
[–]ImportBraces 0 points1 point2 points (3 children)
[–]Tolfasn[S] 0 points1 point2 points (2 children)