【发布时间】:2021-05-02 10:37:34
【问题描述】:
晚上好
大家好,我想从这个网站上抓取图片
https://unsplash.com/t/wallpapers
是的,我知道他们确实有 API,但我想先使用我的编码技能,然后再使用 API。
现在这是我的代码:
from requests_html import HTMLSession
session = HTMLSession()
url ="https://unsplash.com/t/wallpapers"
r = session.get(url)
r.html.render(sleep=3)
images = r.html.find("._2UpQX")
imglinks =[]
for image in images:
imglinks.append(image.attrs["src"])
imglinks
print(imglinks)
我只能获得 6 个图片链接 :(
这是输出的图像,也是所述网站的 css
输出:Output
网站CSS:CSS of website
【问题讨论】:
标签: python css web-scraping xpath python-requests-html