Fwd: Hello

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • spandana g

    Fwd: Hello

    Hello ,

    Traceback (most recent call last):
    File "C:\Python25\ha di_yahoo.py", line 12, in <module>
    file_source.wri te(urllib2.urlo pen(req).read() )
    File "C:\Python25\li b\urllib2.py", line 124, in urlopen
    return _opener.open(ur l, data)
    File "C:\Python25\li b\urllib2.py", line 387, in open
    response = meth(req, response)
    File "C:\Python25\li b\urllib2.py", line 498, in http_response
    'http', request, response, code, msg, hdrs)
    File "C:\Python25\li b\urllib2.py", line 425, in error
    return self._call_chai n(*args)
    File "C:\Python25\li b\urllib2.py", line 360, in _call_chain
    result = func(*args)
    File "C:\Python25\li b\urllib2.py", line 506, in http_error_defa ult
    raise HTTPError(req.g et_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='Moz illa/3.0(compatible; MISE 5.5;Windows NT)'
    headers={'User-Agent':user_age nt}
    req=urllib2.Req uest(url,None,h eaders)
    file_source.wri te(urllib2.urlo pen(req).read()

    its still giving the error mentioned above .. Iam accessing the yahoo search
    engine .. link is "http://search.yahoo.co m/search?n=20&p=i pod"

    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@ gmail.com>
    Date: Thu, Jul 3, 2008 at 2:52 PM
    Subject: HTTP request error with urlopen
    To: python-list@python.org


    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&h l=en&q=ipod&btn G=Search'
    file_source=fil e("google_sourc e.txt",'w')
    file_source.wri te(urlopen(stri ng).read())
    page_content=fi le_source.readl ines()

    Traceback (most recent call last) :
    File "C:/Python25/google.py", line 5,in <module>
    file_source.wri te(urlopen(stri ng).read())
    File "C:\Python25\li b\urllib2.py", line 124 , in urlopen
    return__opener. open(url, data)
    File "C:\Python25\li b\urllib2.py", line 387 , in open
    response =meth(req, response)
    File "C:\Python25\li b\urllib2.py", line 498 , in http_response
    'http', request, response, code, msg, hdrs)
    File "C:\Python25\li b\urllib2.py", line 425, in error
    return self._call_chai n(*args)
    File "C:\Python25\li b\urllib2.py", line 360, in __call_chain
    result = func(*args)
    File "C:\Python25\li b\urllib2.py", line 506, in http_error_defa ult
    raise HTTPError(req.g et_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.

Working...