Re: How to read webpage

2009-08-02 Thread catafest
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  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: 
>
> I've just tried it. I didn't get an exception, so your problem must be
> elsewhere.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read webpage

2009-08-01 Thread James Matthews
Check your connection to the internet.

On Sat, Aug 1, 2009 at 6:43 PM, Marcus Wanner  wrote:

> On 8/1/2009 11:31 AM, Jon Clements wrote:
>
>> On 1 Aug, 14:52, MRAB  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: 

>>> 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.
>>
>
> 'getaddrinfo failed' means that the nameserver can't be found, or that it
> has no records of that address (I'm 90% sure of that).
>
> Marcus
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read webpage

2009-08-01 Thread Marcus Wanner

On 8/1/2009 11:31 AM, Jon Clements wrote:

On 1 Aug, 14:52, MRAB  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: 

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.


'getaddrinfo failed' means that the nameserver can't be found, or that 
it has no records of that address (I'm 90% sure of that).


Marcus
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to read webpage

2009-08-01 Thread Jon Clements
On 1 Aug, 14:52, MRAB  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: 
>
> 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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read webpage

2009-08-01 Thread koranthala
On Aug 1, 6:52 pm, MRAB  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: 
>
> 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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read webpage

2009-08-01 Thread MRAB

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: 


I've just tried it. I didn't get an exception, so your problem must be
elsewhere.
--
http://mail.python.org/mailman/listinfo/python-list


How to read webpage

2009-08-01 Thread tarun
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: 
-- 
http://mail.python.org/mailman/listinfo/python-list