This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
用python爬虫保存美国农业部网站上的水果【证件照】 #114
Labels
Comments
可以商用吗? |
这个不错,可以保存以下,给我女儿看看 |
@catroll 确实, 小孩子应该挺喜欢这种风格的水果图片的 |
@Kingson 不清楚, 我还没有找到特别明确的版权说明. 建议在usda网站上再找找 😭 |
可以再爬个维基把中英文对照替换 |
应该是网络原因导致图片失真 |
@screamff 好想法 |
我也爬了这个,全是大图,转还成了webp格式。 |
可以的,比较好练手,没啥反爬策略 |
ValueError: A pseudo-class must be prefixed with a tag name. |
404 |
还真是, 最新的地址在这里, 不过网页结构都变了, 自动化的 python 脚本估计是不能直接用了 https://naldc.nal.usda.gov/usda_pomological_watercolor?q=&search_field=all_fields |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
美国农业部为全世界已知水果制作了 7500 幅水彩「证件照」并提供高清下载,链接在这里
这次的爬虫的目的是保存这些证件照到本地磁盘。
分析
原页面共收录了7584张图片,分为380页,每页20条。
第一页的链接:
https://usdawatercolors.nal.usda.gov/pom/search.xhtml?start=0
第二页的链接:
https://usdawatercolors.nal.usda.gov/pom/search.xhtml?start=20
...
以此类推,还是比较简单的。
每条数据的HTML元素布局如下:
我们可以获取到:
点击图片进入到详情页面:
点击
Download high resolution
按钮,我们就可以获取到原图了。但是这样的话就意味着每张图都要打开一个新的页面,后来发现缩略图的url和原图的url有关联:
../download/POM00007435/thumbnail
https://usdawatercolors.nal.usda.gov/pom/download.xhtml?id=POM00007435
我们只要从缩略图的url中获取到POM00007435,就可以拼出对应的原图地址了。
爬虫
依赖
源码
Github
usda-fruit-img-spider
打包好的images.zip(大图,非原图), 1.1Gb
The text was updated successfully, but these errors were encountered: