2021-12-12

Tech Programing

程式人小天地

HTTP Error 429 on Linux server, but not my local machine?

2 min read


I’m running a Python program that downloads one single video from YouTube every hour using Pytube onto my local machine and I have no problems with it at all. However, when I deploy the same program onto my Linux server, I receive the following error:

urllib.error.HTTPError: HTTP Error 429: Too Many Requests

Does anyone know why this is or what I can do to fix it? I’m using a Linode Shared CPU running Ubuntu 21.10.

Here is the full error:

Traceback (most recent call last):
  File "/root/main.py", line 137, in <module>
    main_function()
  File "/root/main.py", line 131, in main_function
    get_screenshot()
  File "/root/main.py", line 60, in get_screenshot
    video = youtube.streams.get_highest_resolution()
  File "/usr/local/lib/python3.9/dist-packages/pytube/__main__.py", line 291, in streams
    self.check_availability()
  File "/usr/local/lib/python3.9/dist-packages/pytube/__main__.py", line 206, in check_availability
    status, messages = extract.playability_status(self.watch_html)
  File "/usr/local/lib/python3.9/dist-packages/pytube/__main__.py", line 98, in watch_html
    self._watch_html = request.get(url=self.watch_url)
  File "/usr/local/lib/python3.9/dist-packages/pytube/request.py", line 53, in get
    response = _execute_request(url, headers=extra_headers, timeout=timeout)
  File "/usr/local/lib/python3.9/dist-packages/pytube/request.py", line 37, in _execute_request
    return urlopen(request, timeout=timeout)  # nosec
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 555, in error
    result = self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 429: Too Many Requests



Source link

資料來源:Stackoverflow

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *