首页 > 解决方案 > 如何在python的Scrapy中为爬虫设置xpath

问题描述

如何为爬虫设置 xpath(我正在使用 Crapy 库)?请帮我

网址:https ://www.drugbank.vn/danh-sach/co-so-kinh-doanh


我在下面做了代码,但没有得到数据

def parse(self, response):

    questions = Selector(response).xpath('//jhi-main/jhi-danh-sach')

    for question in questions:

        item = DrugbankItem()

        item['Name'] = question.xpath('div[@class="card border-0"]/div[@class="card-body"]/div[@class="table-responsive"]/table[@class="table table-striped table-bordered"]/tbody/tr/td[1]/text()').extract_first()
        yield item

谢谢!! 在此处输入图像描述

在此处输入图像描述

标签: python

解决方案


推荐阅读