0

Getting page 404 with Python Requests but I can access the page no problem through my browser. I can access other pages that are formatted exactly the same as this page and they load no problem.

Have already tried changing headers with no luck.

My Code:

string_page = str(page)
with requests.Session() as s:

    resp = s.get('https://bscscan.com/token/generic-tokentxns2?m=normal&contractAddress=0x470862af0cf8d27ebfe0ff77b0649779c29186db&a=&sid=f58c1cdefacc680b799412c7645ed7f7&p='+string_page)

    page_info = str(resp.text)

print(page_info)

I have also tried with urllib and the same thing happens

  • Have you tried [sending an “user-agent” using Requests library in Python](https://stackoverflow.com/questions/10606133/sending-user-agent-using-requests-library-in-python)? Maybe "the user-agent should be specified as a field in the header." – dot.Py May 26 '21 at 13:55
  • You probably need to be signed in to get to the page in the URL. When you use Python, it's accessing the page as a "guest". – not_speshal May 26 '21 at 14:09
  • tried the header solutions. no luck. – Stephen Hughes May 26 '21 at 14:33
  • im not logged in on my browser and it still works – Stephen Hughes May 26 '21 at 14:33
  • You perhaps logged in earlier and the browser remembered cookies and which is why it works for you. However, you should share the url to get more accurate suggestion, not like the broken one in your post. – SIM May 26 '21 at 15:20
  • i dont have an account on the website, so have never logged in. This is the direct link to the page: https://bscscan.com/token/generic-tokentxns2?m=normal&contractAddress=0x470862af0cf8d27ebfe0ff77b0649779c29186db&a=&sid=f58c1cdefacc680b799412c7645ed7f7&p=1 – Stephen Hughes May 26 '21 at 15:30

1 Answers1

0

I'm not sure if this will fix it, but try adding this in the header maybe it might work

'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'