I've sometimes problems with encoding and sometimes problems with
IOError: Stream is closed, problems aren't really reproducible, but
this link "
http://forums.mysql.com/read.php?10,146117,146155" gives
again errors, where are problems in my code?
This is my code:
import lxml.html as jq
[...]
class someClass(BaseHandler):
@tornado.web.asynchronous
def post(self):
urlink=self.get_argument("url")
self.set_header("Content-Type", "application/javascript")
http = tornado.httpclient.AsyncHTTPClient()
self.reqUrl = urlink
http.fetch(urlink, callback=self.on_response, headers={"Accept-
Encoding":"gzip,deflate"})
def on_response(self, response):
if response.error: raise tornado.web.HTTPError(500)
html = jq.document_fromstring(response.body)
html.make_links_absolute(self.reqUrl, resolve_base_href=True)
uid = str(uuid.uuid1())
sha = hashlib.sha1()
sha.update(uid)
myUid = sha.hexdigest()
counter = 0
theImg = "none"
theTitle = "none"
try:
for img in html.xpath("//img"):
if (counter < 1):
theImg = img.attrib['src']
counter += 1
else:
pass
except:
theImg = "none"
print title.text_content().replace("\n", "")
theTitle = title.text_content().replace("\n", "")
self.write("[{\"tle\":\""+theTitle+"\",\"img\":\""+theImg+"\",\"uid\":
\""+myUid+"\"}]")
self.finish()
On Sep 18, 11:59 pm, Phil Whelan <
phil...@gmail.com> wrote:
> Sounds like the same problem I was encountering, which was solved by
> grabbing the latest from Github.
https://groups.google.com/forum/#!topic/python-tornado/xx9-47Waha4/di...
>
> Phil
>
>
>
>
>
>
>
>
>
> On Sun, Sep 18, 2011 at 2:33 PM, Ben Darnell <
b...@bendarnell.com> wrote:
> > I can't reproduce the problem myself, but this is most likely the
> > chunked-close bug, which is dependent on network timing. It's fixed in the
> > soon-to-be-released version 2.1.
>
> > -Ben
>
> > On Sun, Sep 18, 2011 at 12:30 PM, Fabio[mbutubuntu]Buda <
> >
mbutubu...@yahoo.it> wrote:
>
> >> I've discovered an error with an URL when requested with httpclient,
> >> almost all URLs work without any problem (also HTTPS that in previous
> >> version caused errors), but this URL "
http://forums.mysql.com/read.php?
> >> 10,146117,146155 <
http://forums.mysql.com/read.php?10,146117,146155>"