【发布时间】:2020-03-10 01:56:30
【问题描述】:
我目前正在处理抓取 baka-update 的 HTML。 但是,Div Class 的名称是重复的。
由于我的目标是 csv 或 json,我想使用 [sCat] 中的信息作为列名,使用 [sContent] 来存储..... 他们是这种网站的方式吗?
谢谢,
示例 https://www.mangaupdates.com/series.html?id=75363
from lxml import html
import requests
page = requests.get('http://www.mangaupdates.com/series.html?id=153558?')
tree = html.fromstring(page.content)
#Get the name of the columns.... I hope
sCat = tree.xpath('//div[@class="sCat"]/text()')
#Get the actual data
sContent = tree.xpath('//div[@class="sContent"]/text()')
print('sCat: ', sCat)
print('sContent: ', sContent)
我试过了,但没有找到 @Jasper Nichol M Fabella
【问题讨论】:
-
到目前为止你尝试了什么?
-
首先我尝试使用 sCat 和 sContent 以及我刚刚添加的图片 2。似乎我可能会在 sContent 中获得一些信息,但我无法在 sCat 中获得任何信息
-
您能否在问题中添加到目前为止您尝试过的代码?
-
刚刚添加!谢谢
标签: python html parsing html-parsing html-parser