1

I'm using requests module to retrieve content from the website kat.cr and here is the code I used:

try:
    response = requests.get('http://kat.cr')
    response.raise_for_status()
except Exception as e:
    print(e)
else:
    return response.text

At first the code works just fine and I could retrieve the website source code, but then it stopped and I keep receiving this message "404 Client Error: Not Found for url: https://kat.cr"

I tried fixing this issue with user-agent like this:

from fake_useragent import UserAgent

try:
    ua = UserAgent()
    ua.update()
    headers = {'User-Agent': ua.random}
    response = requests.get(url, headers=headers)
    response.raise_for_status()
except Exception as e:
    print(e)
else:
    return response.text

But this doesn't seem to work either

Can you please help me fix this problem and thanks.

user3885884
  • 415
  • 3
  • 6
  • 13

1 Answers1

0

I think that, as users suggested, you may be ip-blocked.

Try a proxy.

Proxies with Python 'Requests' module

jwu
  • 11
  • 10