Client side network programming

Roysun_rohit roysun_rohit at
Wed Jun 2 12:23:20 CEST 2004

I am interested in making a search engine which takes web sites
iteratively, and downloads the web page or has to perform some search
across the web pages.
I am unsucessful to do so. My machine works through a proxy server and the
internet connection is through 24 hour lease line. when ever i try the
code it gives :

Traceback (innermost last):
  File "", line 19, in ?
    urllib.urlretrieve(remoteaddr, localname)
  File "/usr/lib/python1.5/", line 66, in urlretrieve
    return _urlopener.retrieve(url, filename, reporthook)
  File "/usr/lib/python1.5/", line 186, in retrieve
    fp =
  File "/usr/lib/python1.5/", line 159, in open
    return getattr(self, name)(url)
  File "/usr/lib/python1.5/", line 260, in open_http
    h = httplib.HTTP(host)
  File "/usr/lib/python1.5/", line 53, in __init__
    if host: self.connect(host, port)
  File "/usr/lib/python1.5/", line 81, in connect
    self.sock.connect(host, port)
IOError: [Errno socket error] (101, 'Network is unreachable')
The code is like this:-
#!/usr/bin/env python
import os, sys, urllib, urlparse, socket
showlines = 6
    servername, filename = sys.argv[1:3]
    servername, filename = '', '/sarsanalysis.html'
remoteaddr = 'http://%s%s' % (servername, filename)
if len(sys.argv) == 4:
   localname = sys.argv[3]
   (scheme, server, path, parms, query, frag) =
   localname = os.path.split(path)[1]
print remoteaddr, localname
urllib.urlretrieve(remoteaddr, localname)
remotedata = open(localname).readlines()
for line in remotedata[:showlines]: print line,
I am new to the internet programming as well as python. please guide me,
how to solve this one.

More information about the Python-list mailing list