我一直在努力刮this page。你知道吗
我似乎无法将“加载更多结果”(法语中的“voir plus de résultats”)加载到我的响应对象中。你知道吗
当我抓取时,我通常使用网络监视技巧来检查AJAX
请求,但是当我单击“加载更多结果”时,没有显示任何活动。这就是为什么我假设结果已经加载,但隐藏了。你知道吗
这是我到目前为止的代码,它返回一个there is no clickable element matching clickdata {'href' :"#"}
。你知道吗
import scrapy
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
from TopAchat.items import TopachatItem
class TopAchatSpider(CrawlSpider):
name = "TopAchat1"
start_urls = ["https://www.topachat.com/pages/marque.php"]
rules = ( Rule(LinkExtractor(restrict_xpaths=('//*[@id="content"]/section/ul[@class="listProduct"]//a'))),
Rule(LinkExtractor(restrict_xpaths=("//li[@class='link-visible']//a","//li[@class='display: list-item']//a")),callback='parse_item'),
)
def parse_item(self, response):
item = TopachatItem()
item["brandname"] = response.xpath("//div[@class='small']/div/text()").extract_first()[4:].split(" ")[0]
item["href"] = response.request.url
item["name"] = response.xpath("//div[@class='libelle']/h1/text()").extract_first()
item["specs"] = response.xpath("//strong[@class='big short-descr']/text()").extract_first()
item["product_type"] = response.xpath("//nav[@class='meta small']//p//b/text()").extract_first()
return item,scrapy.FormRequest.from_response(
response,
clickdata = {'href' :"#"})
我知道还有其他方法来获取数据(Selenium
),但感觉好像我遗漏了一些明显的东西,而且我似乎找不到它。你知道吗
非常感谢您的帮助!你知道吗
他们有以下HTML源代码:
如您所见,它是
//li[@class="link-visible"]/a
(您有这个)和//li/a
(您需要添加这个来捕获“加载更多结果”)相关问题 更多 >
编程相关推荐