Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 05-27-2013, 01:43 PM   #1
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
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 ...
...
hakan42 is offline   Reply With Quote
Old 05-27-2013, 03:23 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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()
kovidgoyal is offline   Reply With Quote
Advert
Old 05-27-2013, 03:32 PM   #3
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
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
hakan42 is offline   Reply With Quote
Old 05-27-2013, 09:45 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 10:48 AM.


MobileRead.com is a privately owned, operated and funded community.