get links?
Martin Johansson
045521104 at telia.com
Fri May 4 04:23:10 EDT 2001
This is my code for saving all the links on one page in a textfile, and
later I will get all these linked pages.
I just started to programing i python so I can´t see what is wrong.
Can anybody help me..
/ Martin Johansson
pt00mjo at student.bth.se
import httplib
import string
import htmllib
import cgi
import sgmllib
def lista(s):
while s != '</HTML>':
if s == '<A HREF="' or s == '<a href="':
while s != '">':
c=open('f.txt', 'a')
c.write(s)
h = httplib.HTTP('www.aftonbladet.se')
h.putrequest('GET', '/vss/handpc/nyheter/0,2183,_ekonomi_1022,00.html')
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
m = h.getfile()
data = m.read()
s = data
print s
s = lista(s)
More information about the Python-list
mailing list