标签:使用 www text bs4 image from inf 文本 src
爬取网页:
http://www.cnblogs.com/xrq730/archive/2018/06/11/9159586.html
抓取的是一个博客的文本内容
1 import requests 2 from bs4 import BeautifulSoup 3
4 5 if __name__==‘__main__‘: 6 target=‘http://www.cnblogs.com/xrq730/archive/2018/06/11/9159586.html‘ 7 req=requests.get(url=target) 8 html=req.text 9 bf=BeautifulSoup(html) 10 texts=bf.find_all(‘div‘,class_=‘blogpost-body‘) 11 #print(html) 12 print(texts[0].text.replace(‘<p><span style=\"font-size: 14px; font-family: 宋体;\">‘,‘\n\n\t‘)) 13 #print(texts[0].text.replace(‘\ax0‘*8,‘\n\n‘))
标签:使用 www text bs4 image from inf 文本 src
原文地址:https://www.cnblogs.com/xy-ju24/p/9204416.html