标签:pychar .text port .com 分享 text 轻松 pat ext
1.在PyCharm安装lxml.
2.找到源码
3.F12、copy源码的xpath
4.代码
from lxml import etree import requests wb_data = requests.get("https://www.baidu.com/").text html = etree.HTML(wb_data) html_data = html.xpath(‘//*[@id="lh"]/a[2]‘); for i in html_data: print(i.text)
标签:pychar .text port .com 分享 text 轻松 pat ext
原文地址:https://www.cnblogs.com/ZaraNet/p/9938347.html