Fwd: Hello



Hello ,

Traceback (most recent call last):
File "C:\Python25\hadi_yahoo.py", line 12, in <module>
file_source.write(urllib2.urlopen(req).read())
File "C:\Python25\lib\urllib2.py", line 124, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 387, in open
response = meth(req, response)
File "C:\Python25\lib\urllib2.py", line 498, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python25\lib\urllib2.py", line 425, in error
return self._call_chain(*args)
File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 999: Unable to process request at this time -- error
999

Previously i got the error which I have attached below when I use just
urlopen . But now when I use this http request
user_agent='Mozilla/3.0(compatible;MISE 5.5;Windows NT)'
headers={'User-Agent':user_agent}
req=urllib2.Request(url,None,headers)
file_source.write(urllib2.urlopen(req).read()

its still giving the error mentioned above .. Iam accessing the yahoo search
engine .. link is "http://search.yahoo.com/search?n=20&p=ipod";

I'm attaching the python file i have written just have a look and suggest me
something that works for this query

Thank You,
Spandana.




---------- Forwarded message ----------
From: spandana g <spandanagella@xxxxxxxxx>
Date: Thu, Jul 3, 2008 at 2:52 PM
Subject: HTTP request error with urlopen
To: python-list@xxxxxxxxxx


Hello ,

I have written a code to get the page source of the google search
page .. this is working for other urls. I have this problem with

import re
from urllib2 import urlopen
string='http://www.google.com/search?num=20&hl=en&q=ipod&btnG=Search'
file_source=file("google_source.txt",'w')
file_source.write(urlopen(string).read())
page_content=file_source.readlines()

Traceback (most recent call last) :
File "C:/Python25/google.py", line 5,in <module>
file_source.write(urlopen(string).read())
File "C:\Python25\lib\urllib2.py", line 124 , in urlopen
return__opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 387 , in open
response =meth(req, response)
File "C:\Python25\lib\urllib2.py", line 498 , in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python25\lib\urllib2.py", line 425, in error
return self._call_chain(*args)
File "C:\Python25\lib\urllib2.py", line 360, in __call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden

Actually urlopen is working for google labs sets page but not for the
google.com and even I have same problem with wikipedia . Please let me know
... If any one of have any idea about this .

Thank You,
Spandana.
import re
import urllib2
from urllib2 import urlopen
string1='http://search.yahoo.com/search?n=20&p='
string2=raw_input("Enter the string here")
user_agent='Mozilla/3.0(compatible;MISE 5.5;Windows NT)'
headers={'User-Agent':user_agent}
url=string1+string2
print url
req=urllib2.Request(url,None,headers)
file_source=file("yahoo_source.txt",'w')
file_source.write(urllib2.urlopen(req).read())
file_data=file("yahoo_source.txt",'r')
filename=string2+'_yahoo_hadi.txt'
output=file(filename,'w')
page_content=file_data.readlines()


Relevant Pages

  • Re: Little problem with C program
    ... 'sizeof request' returns the size of a pointer, ... you need to do with HTTP.) ... > message "Reading response ..." ... That system puts the GET inside the function, so I call it like this: ...
    (comp.programming)
  • Re: Screen Scraping a Password Protected Site
    ... http traffic. ... cookies to a singleton CookieContainer and the once you have logged in ... If TypeOf request Is HttpWebRequest Then ... If TypeOf response Is HttpWebResponse Then ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Using HttpWebRequest and HttpWebResponse
    ... when an HTTP 4xx or 5xx status is returned. ... variable to WebException.Response - the original response. ... a request to http://someaddress/someresource. ...
    (microsoft.public.dotnet.framework)
  • Re: HTTP question
    ... > then before I receive any response back from the server I issue another GET ... > request for a different web page. ... Will I get an error back from the server? ... HTTP client waits for the first response before sending the second ...
    (comp.infosystems.www.servers.misc)
  • Re: urllib2 - 403 that _should_ not occur.
    ... response = meth ... raise HTTPError, code, msg, hdrs, fp) ... urllib2.HTTPError: HTTP Error 403: Forbidden ...
    (comp.lang.python)