Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: How to read webpage

 
Thread Tools Search this Thread
Old 08-01-2009, 02:52 PM   #1
Default Re: How to read webpage


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.


MRAB
  Reply With Quote
Old 08-01-2009, 04:19 PM   #2
koranthala
 
Posts: n/a
Default Re: How to read webpage
On Aug 1, 6:52*pm, MRAB <pyt...@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.


Is it that the website expects a valid browser?
In that case, spoof a browser and try to get the site.


koranthala
  Reply With Quote
Old 08-01-2009, 04:31 PM   #3
Jon Clements
 
Posts: n/a
Default Re: How to read webpage
On 1 Aug, 14:52, MRAB <pyt...@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.


I'm hoping this adds to MRAB's reply; it is intended however for the
OP.

Jeeze -- been a while since I've had to deal with Sockets (directly
anyway).
If memory serves correctly, it's where the system can't name resolve
the required address.
So best guess is it's either a temporary glitch, or an issue with your
routing.

Jon.
Jon.


Jon Clements
  Reply With Quote
Old 08-02-2009, 07:13 PM   #4
catafest
 
Posts: n/a
Default Re: How to read webpage
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...@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.




catafest
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I fix (Internet Explorer cannot display the webpage)? coffeyman MCTS 4 01-26-2009 04:07 PM
Help figuring out why my webpage refreshes to the homepage. Carrie76 General Help Related Topics 1 09-26-2006 02:11 AM
Note to advertisers: Consider this fair warning FAQmeister DVD Video 72 06-19-2004 05:17 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46