How to read webpage
catafest
catalinfest at gmail.com
Sun Aug 2 14:13:13 EDT 2009
Maybe your python2.5 not working good!?
But, I use python 2.6 , and i use this for your problem:
import urllib
html = urllib.urlopen("http://www.rediff.com/").read()
print html
If you want use authenticate then...
You make working urllib2 and use this
>>>auth = urllib2.Request(auth_uri, authreq_data)
On Aug 1, 4:52 pm, MRAB <pyt... at mrabarnett.plus.com> wrote:
> tarun wrote:
> > Dear All,
> > I want to read a webpage and copy the contents of it in word file. I
> > tried to write following code:
>
> > import urllib2
> > urllib2.urlopen("http://www.rediff.com/")
>
> > *Error:-*
>
> > urllib2.urlopen("http://www.icicibank.com/")
> > File "C:\Python25\lib\urllib2.py", line 121, in urlopen
> > return _opener.open(url, data)
> > File "C:\Python25\lib\urllib2.py", line 374, in open
> > response = self._open(req, data)
> > File "C:\Python25\lib\urllib2.py", line 392, in _open
> > '_open', req)
> > File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
> > result = func(*args)
> > File "C:\Python25\lib\urllib2.py", line 1100, in http_open
> > return self.do_open(httplib.HTTPConnection, req)
> > File "C:\Python25\lib\urllib2.py", line 1075, in do_open
> > raise URLError(err)
> > urllib2.URLError: <urlopen error (11001, 'getaddrinfo failed')>
>
> I've just tried it. I didn't get an exception, so your problem must be
> elsewhere.
More information about the Python-list
mailing list