其他分享
首页 > 其他分享> > 抓取天堂网

抓取天堂网

作者:互联网

import requests
from lxml import etree
"""
nodename 	选择这个节点名的所有子节点
/ 	从当前节点选择直接子节点
// 	从当前节点选取子孙节点
. 	选择当前节点
… 	选取当前节点的父节点
@ 	选取属性
"""
response = requests.get('https://www.ivsky.com/tupian/renwutupian/')
print(response.text)
root = etree.HTML(response.content)
img_src = root.xpath("//ul[@class='ali']/li/div/a/img/@src")
for img in img_src:
    img = 'https:'+img
    print(img)

 

标签:选取,src,img,抓取,节点,https,天堂,response
来源: https://blog.csdn.net/A1010574609/article/details/100895142