python tags on websites timeout problem

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

    python tags on websites timeout problem

    Hiya

    im trying to pull tags off a website using python ive got a few things
    running that have the potential to work its just i cant get them to
    becuase of certain errors?

    basically i dont what to download the images and all the stuff just
    the html and then work from there, i think its timing out because its
    trying to downlaod the images as well which i dont what to do as this
    would decrease the speed of what im trying to achieve, the URL used is
    only that for an example

    ive included my source and the errors

    cheers

    greg

    this is my source

    --------------------------------------------------------------------------------

    #!/usr/bin/env python
    import re
    import urllib

    file = urllib.urlretri eve("http://images.google.c om/images?hl=en&lr =&ie=UTF-8&oe=UTF-8&q=rabbit"
    , "temp1.tmp" )

    # open a file
    file = open("temp1.tmp ","r")
    text = file.readlines( )
    file.close()

    # searching the file content line by line:
    keyword = re.compile(r"</a>")

    for line in text:
    result = keyword.search (line)
    if result:
    print result.group(1) , ":", line,
    --------------------------------------------------------------------------------
    and these are the errors im getting

    C:\Python22>pyt hon tagyourit.py
    Traceback (most recent call last):
    File "tagyourit. py", line 5, in ?
    file = urllib.urlretri eve("http://images.google.c om/image
    8&oe=UTF-8&q=rabbit" , "temp1.tmp" )
    File "C:\PYTHON22\li b\urllib.py", line 80, in urlretrieve
    return _urlopener.retr ieve(url, filename, reporthook, dat
    File "C:\PYTHON22\li b\urllib.py", line 210, in retrieve
    fp = self.open(url, data)
    File "C:\PYTHON22\li b\urllib.py", line 178, in open
    return getattr(self, name)(url)
    File "C:\PYTHON22\li b\urllib.py", line 292, in open_http
    h.endheaders()
    File "C:\PYTHON22\li b\httplib.py", line 695, in endheaders
    self._send_outp ut()
    File "C:\PYTHON22\li b\httplib.py", line 581, in _send_outpu
    self.send(msg)
    File "C:\PYTHON22\li b\httplib.py", line 548, in send
    self.connect()
    File "C:\PYTHON22\li b\httplib.py", line 532, in connect
    raise socket.error, msg
    --------------------------------------------------------------------------------
Working...