爬虫 -- Xpath解析
抓取数据
from lxml import etree
html = requests.get(url=product_url)
<!--解析数据-->
html = etree.HTML(html.content)
html_data = html.xpath('/html/body/div/ul/li/a')
使用xpath进行数据定位
<!--这里列举一些语法案例-->
//button[@type='submit']
//section/span[contains(@class,'glyphsSpriteHeart')]/..
//input[@id='username']
//a[contains(@href, "/products/")]/@href
