python简单爬虫示例
python版本:3.6
所需模块:
- requests
- BeautifulSoup
以爬取我博客首页文章列表的标题为例:
from bs4 import BeautifulSoup
import requests
if __name__=="__main__":
target='https://liangxingjian.com'
req=requests.get(url=target)
html=req.text
bf=BeautifulSoup(html,features="html.parser")
texts=bf.find_all('h2',class_='post-title')
for a in texts:
print(a.text)
运行效果:
虽然不是很明白,但谢谢分享。
这个确实不懂,学习学习
我去,python都开始入手了,厉害
哈哈,技术这个不太懂,学习了。