python提取url

2023-01-31 02:01:05 python url 提取

import urllib2
str1='<a title="xxxx" target="_blank" href="Http://xxxx.html">xxxx</a>'
href=str1.find(r'href')
url=str1.find(r'.html')

html = str1[href+6:url+5]
content = urllib2.urlopen(html).read()
print content


相关文章