👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I am trying to use Python to login to a website and gather information from several webpages and I get the following error:
Traceback (most recent call last): File "extract_test.py", line 43, in <module> response=br.open(v) File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout) File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 255, in _mech_open raise response mechanize._response.httperror_seek_wrapper: HTTP Error 429: Unknown Response Code
I used time.sleep()
and it works, but it seems unintelligent and unreliable, is there any other way to dodge this error?
Here"s my code:
import mechanize
import cookielib
import re
first=("example.com/page1")
second=("example.com/page2")
third=("example.com/page3")
fourth=("example.com/page4")
## I have seven URL"s I want to open
urls_list=[first,second,third,fourth]
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
# Log in credentials
br.open("example.com")
br.select_form(nr=0)
br["username"] = "username"
br["password"] = "password"
br.submit()
for url in urls_list:
br.open(url)
print re.findall("Some String")
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from How to avoid HTTP error 429 (Too Many Requests) python, check other ast Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano How to avoid HTTP error 429 (Too Many Requests) python
- Deutsch How to avoid HTTP error 429 (Too Many Requests) python
- Français How to avoid HTTP error 429 (Too Many Requests) python
- Español How to avoid HTTP error 429 (Too Many Requests) python
- Türk How to avoid HTTP error 429 (Too Many Requests) python
- Русский How to avoid HTTP error 429 (Too Many Requests) python
- Português How to avoid HTTP error 429 (Too Many Requests) python
- Polski How to avoid HTTP error 429 (Too Many Requests) python
- Nederlandse How to avoid HTTP error 429 (Too Many Requests) python
- 中文 How to avoid HTTP error 429 (Too Many Requests) python
- 한국어 How to avoid HTTP error 429 (Too Many Requests) python
- 日本語 How to avoid HTTP error 429 (Too Many Requests) python
- हिन्दी How to avoid HTTP error 429 (Too Many Requests) python
Boston | 2023-02-07
Thanks for explaining! I was stuck with How to avoid HTTP error 429 (Too Many Requests) python for some hours, finally got it done 🤗. I just hope that will not emerge anymore
Rome | 2023-02-07
Thanks for explaining! I was stuck with How to avoid HTTP error 429 (Too Many Requests) python for some hours, finally got it done 🤗. I just hope that will not emerge anymore
Moscow | 2023-02-07
re Python module is always a bit confusing 😭 How to avoid HTTP error 429 (Too Many Requests) python is not the only problem I encountered. Will use it in my bachelor thesis