简体   繁体   English

504:urllib2的网关超时

[英]504 : Gateway Timeout with urllib2

When I try to read the source of the page , I get the following output 当我尝试读取页面的来源时,我得到以下输出

  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

My code.py (After removing irrelevant stuff) : 我的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")

How can I resolve this ? 我该如何解决这个问题? Is the redirection of l_link causing problem over here ? l_link的重定向是否导致了问题? Thanks in Advance. 提前致谢。

PS : I've already searched for the problem and couldn't find anything useful. PS:我已经搜索过这个问题,找不到任何有用的东西。

5xx status codes are problems with the server (compared with 4xx status codes, which are problems with the client). 5xx状态代码是服务器的问题(与4xx状态代码相比,这是客户端的问题)。 This means you sent the server a valid request, but the server was unable to serve a valid response. 这意味着您向服务器发送了有效请求,但服务器无法提供有效响应。

Your code is fine, but the server (or in this case, a gateway that the server is using) is having problems. 您的代码很好,但是服务器(或者在这种情况下,服务器正在使用的网关)遇到了问题。 You just need to wait patiently for the server to resolve its own issues, or contact the server administrator and inform them that their server is misbehaving. 您只需要耐心等待服务器解决自己的问题,或者联系服务器管理员并告知他们他们的服务器行为不端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM