#! /usr/bin/env python
#coding=utf-8
from urllib import urlopen
import time
url = ['']*40
i = 0
arti = urlopen('http://blog.sina.com.cn/s/articlelist_1227636382_0_1.html').read()
title = arti.find(r'<a title=')
href = arti.find(r'href=',title)
html = arti.find(r'.html',href)
url[0] = arti[href+6:html+5]
print url
while title != -1 and href != -1 and html != -1 and i<40:
url[i] = arti[href+6:html+5]
print url[i]
title = arti.find(r'<a title=',html)
href = arti.find(r'href=',title)
html = arti.find(r'.html',href)
i = i + 1
else:
print 'find end'
j=0
while j<50:
content = urlopen(url[j]).read()
filename = url[j][-26:]
print filename
open(r'yishu/'+url[j][-26:],'w+').write(content)
print 'downloading',url[j]
j = j+1
time.sleep(1)
else:
print 'download article finished'