[Tutor] html programming ???
Samir Patel
sampatel@cs.rmit.edu.au
Tue, 2 Oct 2001 19:13:49 +1000 (EST)
hi all,
i am trying to write python script which takes a url and opens that page
...then i am trying to grab all the links present in that page and want
to put that links in a data structure.....
now my problem is that how do i use a data structure and how should i put
this links into that.....
following is my code :
#!/usr/local/bin/python
import sys
import urllib
import re
url = sys.argv[1]
try:
fp = urllib.urlopen(url)
except IOError:
fp = ('*** ERROR: invalid URL ***')
done = 0
while not done:
line = fp.readline()
if line != "":
link = re.findall('href="(.*?)"', line)
if len(link) != 0:
for get_link in link:
print url + " " + "->" + " " + get_link
else:
done=1
fp.close()
hopw u guys can help me !!!!
thanks
samir