from bs4 import BeautifulSoup as bsp import re import lxml from datetime import datetime
with open(r"d:\\picurl.txt") as f: text=f.read() csp=bsp(text,"lxml") print(u"已经获取地址文件,马上提取图片地址!") d=csp.find_all('img',src=re.compile('[a-zA-z]+://[^\s]*jpg')) for url in d: print(url.get("src")) with open("D:\\url.txt",'a') as f: f.write("wget "+url.get("src")+"\n") with open(datetime.now().date().isoformat()+'.html',"a") as f: f.write("<img src=\""+url.get("src")+"\"><p></p>")