![]() |
#1 |
Zealot
![]() Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
|
How to detect HTTP conditions in jsbrowser/browser.py
I am building an OPDS client for Beam EBooks with calibre-0.9.31
While testing, I managed to create a broken URL, making the server return HTTP code 203 to me, which seems to be written to the log file only... Is there a way for me to catch this condition? My code looks like (reduced to the bare minimum) Code:
from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.web.jsbrowser.browser import Browser ... self.browser = Browser(enable_developer_tools=True) ... self.browser.visit(url) soup = BeautifulSoup(self.browser.html) ... ... further processing here ... ... |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,318
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Whya re you using jsbrowser to parse OPDS? use the mechanize based browser instead, which will raise exceptions for HTTP error codes.
from calibre import browser br = browser() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
|
It was the first thing I found while browsing the source tree and google hits :screwy:
I will follow your hint and switch to mechanize |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,318
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
jsbrowser is meant for scraping websites that rely on javascript. For everytghing else, use mechanize.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
What are: url:http|// ... urn:urn|uuid| ... uri:http|// | 44reader | Library Management | 5 | 07-05-2012 01:42 PM |
How do I suppress Stack Traces on HTTP 404 Error in the web browser? | katsu | Development | 3 | 11-06-2011 11:25 PM |
Pocketbook manufacturing conditions | jmawhorter | PocketBook | 14 | 08-28-2010 08:24 PM |
Lighting conditions of the 700. | Andybaby | Sony Reader | 1 | 02-19-2009 10:41 PM |
Speaking to me:Terms and Conditions | Bob Russell | Lounge | 1 | 11-14-2005 09:01 AM |