如何使用scrapy抓取没有类和更改id的html标签?

qij5mzcb  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(120)

我想从http://house.speakingsame.com/p.php?q=Brisbane+City&sta=qld中刮出房产的售价
它没有格式,没有类,内容以表格表示。

在这种情况下,我应该怎么做?2每个表代表每个属性。3我需要每个属性的销售价格,因此每个表。
response.css('tbody').getall()不返回任何内容。

lnlaulya

lnlaulya1#

使用xpath,您可以用途:

for element in response.xpath("//table//table//table"):
    sold = element.xpath(".//b")[0].xpath("./text()").get()
    print(sold)
    date = element.xpath(".//td")[0].xpath("./text()").get()

输出:

Sold $640,000
Sold $640,000
Sold $320,000
Sold $320,000
Sold $145,000
Sold $145,000
Sold $145,000
Sold $145,000
Sold $239,000
Sold $239,000
Sold $695,000
Sold $695,000
Sold $740,000
Sold $740,000
Sold $375,000
Sold $375,000
Sold $390,000
Sold $390,000
Sold $695,000
Sold $695,000

相关问题