查看网页元素,不知道怎么定位到链接
如图所示,不知道怎样定位到该链接,求各位大佬帮帮忙,越详细越好,谢谢 import requestsfrom lxml import etree
if __name__ == '__main__':
url="http://live.500.com/"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'}
response = requests.post(url,headers=headers)
response.encoding="gb2312"
res = etree.HTML(response.text)
href = res.xpath("//td[@align='center']/a/@href")
print(href)
以BeautifulSoup为例,假设变量a是定位到标签<a>的,a['href']就行了 wp231957 发表于 2020-2-25 08:53
谢谢你,但我复制了还有问题,我再改下,要是不行,再求助
页:
[1]