python - IOError: Error reading file: failed to load HTTP resource, LXML error in Pythonanywhere -


i having problem using lxml python 2.7. tried installing lxml version 3.4.0 , 3.4.2 got same error no idea why tho. here python code:

@app.route("/getinformation", methods=['get'])            def domain():       urllist = []      urllist.append("http://gbgfotboll.se/serier/?scr=table&ftid=57109")     urllist.append("http://gbgfotboll.se/serier/?scr=table&ftid=57108")      date = '2015-04-18'      # use in real mode: currentdate = (time.strftime("%y-%m-%d"))      homescore = "0"     awayscore = "0"     hometeam = ""     awayteam = ""      time_xpath = xpath("td[1]/span/span//text()[2]")     team_xpath = xpath("td[2]/a/text()")     league_xpath = xpath("//*[@id='content-primary']/h1//text()")      url in urllist:         test =  0 #remove         rows_xpath = xpath("//*[@id='content-primary']/table/tbody/tr[td[1]/span/span//text()='%s']" % (date))         html = lxml.html.parse(url)     .... 

and here errors get:

2015-03-28 13:12:23,852 :exception on /getinformation [get] traceback (most recent call last):   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app     response = self.full_dispatch_request()   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request     rv = self.handle_user_exception(e)   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception     reraise(exc_type, exc_value, tb)   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request     rv = self.dispatch_request()   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request     return self.view_functions[rule.endpoint](**req.view_args)   file "/home/timocin/mysite/work.py", line 48, in domain     html = lxml.html.parse(url)   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/lxml/html/__init__.py", line 786, in parse     return etree.parse(filename_or_url, parser, base_url=base_url, **kw)   file "lxml.etree.pyx", line 3299, in lxml.etree.parse (src/lxml/lxml.etree.c:72655)   file "parser.pxi", line 1791, in lxml.etree._parsedocument (src/lxml/lxml.etree.c:106263)   file "parser.pxi", line 1817, in lxml.etree._parsedocumentfromurl (src/lxml/lxml.etree.c:106564)   file "parser.pxi", line 1721, in lxml.etree._parsedocfromfile (src/lxml/lxml.etree.c:105561)   file "parser.pxi", line 1122, in lxml.etree._baseparser._parsedocfromfile (src/lxml/lxml.etree.c:100456)   file "parser.pxi", line 580, in lxml.etree._parsercontext._handleparseresultdoc (src/lxml/lxml.etree.c:94543)   file "parser.pxi", line 690, in lxml.etree._handleparseresult (src/lxml/lxml.etree.c:96003)   file "parser.pxi", line 618, in lxml.etree._raiseparseerror (src/lxml/lxml.etree.c:95015) ioerror: error reading file 'http://gbgfotboll.se/serier/?scr=table&ftid=57109': failed load http resource 

i using same code on , worked fine. changed server have no idea why im getting error. ideas?

edit1

i tried using urllib2 instead , got following message:

2015-03-28 15:15:05,087 :exception on /getinformation [get] traceback (most recent call last):   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app     response = self.full_dispatch_request()   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request     rv = self.handle_user_exception(e)   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception     reraise(exc_type, exc_value, tb)   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request     rv = self.dispatch_request()   file "/home/timocin/mysite/env/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request     return self.view_functions[rule.endpoint](**req.view_args)   file "/home/timocin/mysite/work.py", line 57, in domain     p = urlopen(url)   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) httperror: http error 403: forbidden 

edit2

i found out need have payed account access external websites. bought account , still dont work error messages changed, lxml:

ioerror: error reading file 'https://gbgfotboll.se/serier/?scr=table&ftid=57109': failed load external entity "https://gbgfotboll.se/serier/?scr=table&ftid=57109" 

and urllib2

urlerror: <urlopen error [errno 111] connection refused> 


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -