import urllib
import time
con=urllib.urlopen('http://blog.sina.com.cn/s/articlelist_1191258123_0_1.html').read()
url=['']*50
title=con.find(r'<a title=')
href=con.find(r'href=',title)
html=con.find(r'.html',href)
x=0
while title!=-1 and href!=-1 and html!=-1 and x<50:
url[x]=con[href+6:html+5]
print '%d' % x,url[x]
title=con.find(r'<a title=',html)
href=con.find(r'href=',title)
html=con.find(r'.html',href)
x+=1
else:
'find end'
j=0
while j<50:
content=urllib.urlopen(url[j]).read()
open(r'hanhan/'+url[j][-26:],'w').write(content)
print 'downloading',url[j]
j+=1
time.sleep(1)
else:
'download the articles'
import time
con=urllib.urlopen('http://blog.sina.com.cn/s/articlelist_1191258123_0_1.html').read()
url=['']*50
title=con.find(r'<a title=')
href=con.find(r'href=',title)
html=con.find(r'.html',href)
x=0
while title!=-1 and href!=-1 and html!=-1 and x<50:
url[x]=con[href+6:html+5]
print '%d' % x,url[x]
title=con.find(r'<a title=',html)
href=con.find(r'href=',title)
html=con.find(r'.html',href)
x+=1
else:
'find end'
j=0
while j<50:
content=urllib.urlopen(url[j]).read()
open(r'hanhan/'+url[j][-26:],'w').write(content)
print 'downloading',url[j]
j+=1
time.sleep(1)
else:
'download the articles'