爬取国家地理画廊 想爬取点击图片链接进去页面的图片,如何爬取,现在下面的代码只能爬取当前页面的图片与内容,如何修改才能实现爬取图片里面那个链接的内容?
import requests
from lxml import etree
r_url = 'http://www.dili360.com/gallery'
res = requests.get(r_url)
res_html = etree.HTML(res.text)
title = res_html.xpath("/html/body/div[1]/div[3]/ul/li/div[2]/h3/text()")
img_srcs = res_html.xpath("/html/body/div[1]/div[3]/ul/li/div[1]/a/img/@src")
print(img_srcs)
img_lst = []
for item in title:
print(item)
for src in img_srcs:
print(src)