requests.exceptions.InvalidURL: Failed to parse

11,555

This is actually something with the urllib3 library because requests parses the url with urllib3, urllib3's parser isn't percent-encoding characters within the userinfo section of the URL, just upgrade your urllib3 it will work.

How to upgrade or install ?

python -m pip install --upgrade urllib3

pip install urllib3

from github repository:

git clone git://github.com/urllib3/urllib3.git
cd urllib3
python setup.py install
Share:
11,555

Related videos on Youtube

Author by

Oussama Hamad

Updated on June 04, 2022

Comments

  • Oussama Hamad 12 months

    I think my code is clean and simple , but i got this error :

    requests.exceptions.InvalidURL: Failed to parse: http://support
    .google.com/
    

    When trying to run it .

    I don't know why actually i tried too many things

    when i change

    fuzing_website_response = requests.get(f'http://{i}.{take_input}/')
    

    to

    fuzing_website_response = requests.get(f'http://{take_input}/{i}')
    

    and run it and with valid URL input _ > it will give me the responses status_code successfully .

    But the other code which try to enumerate subdomains given me the provided error even when http://support.google.com is a valid url

    Detailed response with the reason of the problem will be appreciated.

    Script code :

    
    take_input = input('Enter the website > ')
    take_file = open('list.txt','r')
    for i in take_file:
        fuzing_website_response = requests.get(f'http://{i}.{take_input}/')
        print (f'{take_input}/{i} ---> {fuzing_website_response.status_code}')
    
    • Pedro Rodrigues
      Pedro Rodrigues over 3 years
      It seems the string you pass as an url has newline character in it. I believe you can mitigate this by stripping i, i = i.strip().
    • DisappointedByUnaccountableMod
      DisappointedByUnaccountableMod over 3 years
      In general, why don’t you simply print the URL before you try to use it - then you can see if it looks strange.
    • Oussama Hamad over 3 years
      Can u re write the code for me , i didn't understand .. sorry but i'm noob/beginner in python