簡體   English   中英

504:urllib2的網關超時

[英]504 : Gateway Timeout with urllib2

當我嘗試讀取頁面的來源時,我得到以下輸出

  Traceback (most recent call last):
  File "price.py", line 179, in <module>
    l_soup = BeautifulSoup(urllib2.urlopen(l_link).read())
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 504: Gateway Time-out

我的code.py(刪除不相關的東西后):

isbn = str(9780593072493)
l_link = "http://www.landmarkonthenet.com/books/search/"+isbn
l_soup = BeautifulSoup(urllib2.urlopen(l_link).read())
l_temp = l_soup.select(".price-current")

我該如何解決這個問題? l_link的重定向是否導致了問題? 提前致謝。

PS:我已經搜索過這個問題,找不到任何有用的東西。

5xx狀態代碼是服務器的問題(與4xx狀態代碼相比,這是客戶端的問題)。 這意味着您向服務器發送了有效請求,但服務器無法提供有效響應。

您的代碼很好,但是服務器(或者在這種情況下,服務器正在使用的網關)遇到了問題。 您只需要耐心等待服務器解決自己的問題,或者聯系服務器管理員並告知他們他們的服務器行為不端。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM