1

Beautiful Soup works in the Python shell using Django. I can also successfully import from bs4 import BeautifulSoup into views.py, but when I call something like soup = BeautifulSoup(xml), I get a 502 Bad Gateway error. I talked to my host, and they could not find the problem. Any ideas?

Note the xml is xml = urllib2.urlopen("http://isbndb.com/api/books.xml?access_key=000000&results=details&index1=isbn&value1=0000").read(), but it works in the Python shell (within myproject folder), so I wouldn't think that's the problem.

AAA
  • 1,962
  • 4
  • 30
  • 55
  • 1
    That error wouldn't have anything to do with BeautifulSoup. It is likely a problem on the server from which you are retrieving your data. – Andbdrew Apr 19 '12 at 19:45
  • I already submitted a support ticket, and they said it's a problem on my front. – AAA Apr 19 '12 at 23:01
  • Like I said, I can call `soup = BeautifulSoup(xml)` in my shell but when I call it from `views.py` I get the 502 bad gateway. If I comment it out, I don't get the 502 bad gateway. `from bs4 import Beautiful Soup` works in both views.py and in the shell though. – AAA Apr 19 '12 at 23:12

2 Answers2

1

This sounds like the interaction between Cython and mod_wsgi described here, and explored in a Beautiful Soup context here.

Leonard Richardson
  • 3,994
  • 2
  • 17
  • 10
  • I re-explained the problem to my host, and they told me I had to install an older version of Beautiful Soup and so I did. It works now. FWIW, I removed lxml since I don't use it for any of my apps. – AAA Apr 20 '12 at 02:24
0

Try copying and pasting that URL into your browser. I get an access key error; fix that and your problem is solved.

  • Um. No. The reason it has an error is because I took out the actual API access key and ISBN key. `000000` and `0000` aren't the actual numbers. – AAA Apr 19 '12 at 23:01
  • I recommend you try being a bit more polite when asking for help. Have a nice day. –  Apr 20 '12 at 05:54