1

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) :

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 ? Thanks in Advance.

PS : I've already searched for the problem and couldn't find anything useful.

GingerNinja23
  • 162
  • 2
  • 11

1 Answers1

3

5xx status codes are problems with the server (compared with 4xx status codes, which are problems with the client). 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.

Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
  • `u_link = "http://www.uread.com/search-books/"+isbn` `u_soup = BeautifulSoup(urllib2.urlopen(u_link).read())` `u_temp = u_soup.find(id="ctl00_phBody_ProductDetail_lblourPrice")` The same thing happens with this also , though both the servers respond fine when the request is sent from a browser. :( – GingerNinja23 Dec 26 '13 at 02:22
  • @GingerNinja23: Your code works fine for me. Are you able to download the URL from the command line, e.g. `curl -L http://www.landmarkonthenet.com/books/search/9780593072493`? Have you tried using Wireshark to trace the packets being sent to make sure everything is as you expect? – Adam Rosenfield Dec 26 '13 at 02:27
  • Thanks for the help Adam. I was trying the code on koding.com and it wasn't working there for some reason. I've tried it on my PC now. Both curl and the code work fine :) – GingerNinja23 Dec 26 '13 at 02:37