Files
kenney-asset-scrapper/思路.txt
2025-04-23 16:46:52 +08:00

33 lines
1.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
我想要爬取这个网页 https://www.kenney.nl/assets/page:1 下(共有 13 页)
//*[@id="content"]/section/div/div[1] 这个元素(里边是 n 个 div 元素)
我需要获取每个 Div 元素的
//*[@id="content"]/section/div/div[1]/div[1]/div/a 这个 a 元素
将它的链接保存成一个列表
然后依次访问这个列表中的所有页面,
CSV 格式如下:
资源名称, 分类, 系列, 资源数, 标签(有多个),资源数量
访问这个界面,然后我需要获取它的所有信息:
资源名称://*[@id="content"]/section/div/div/div[1]/h1
各种属性://*[@id="content"]/section/div/div/div[1]/table[1]/tbody
上面这个表,他是个两列 N 行的表。
表的左侧可以看作是 key: Category, Series, Assets, Variation(s), Tags, License 等……
表的右侧是 Value但它可能会有各种组成方式下边是常见的
- 普通的 td > a
- 只有 td
- td 之后有多个 a如 Tags)
更新记录://*[@id="content"]/section/div/div/div[1]/table[2]/tbody
他也是个两行 N 列的表,
左侧是更新日期 dd/mm/yyyy
右侧是 td > 第一个 span 是版本,第二个 span 是更新内容,有时候没有第二个 span
继续增加 parse_resource_page(url) 函数,
我需要获取它的封面图://*[@id="content"]/section/div/div/div[2]/a/img
以及其他图片(如有)
//*[@id="content"]/section/div/div/div[2]/div 这里子元素可能有 n 个 div我需要拿到它的 img
//*[@id="content"]/section/div/div/div[2]/div/div[1]/a/img
封面图存了之后,也得加在图集的数组里。