使用帖子方法刮擦多个页面
import scrapy
from scrapy.http import Request
from scrapy.selector import Selector
from selenium import webdriver
import time
from scrapy_selenium import SeleniumRequest
class TestSpider(scrapy.Spider):
name = 'test'
url = "https://www.benrishi-navi.com/english/english1_3.php"
payload='serial=19&office_serial=&submit2=Details'
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8,pt;q=0.7',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'CAKEPHP=u6u40lefkqnm45j49a5i0h6bs3',
'Origin': 'https://www.benrishi-navi.com',
'Referer': 'https://www.benrishi-navi.com/english/english1_2.php',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"'
}
def start_requests(self):
yield SeleniumRequest(
url=self.url,
method='POST',
body=self.payload,
wait_time=3,
screenshot=True,
headers=self.headers,
callback=self.parse,
dont_filter=True,
)
def parse(self,response):
title=response.xpath("//td[@class='kiso']//text()").getall()
print(title)
我使用帖子方法从页面上删除数据,但是每个数据都有不同的序列号
这些是页面链接 https://www.benrishi-navi.com/english/english/english1_2.php
然后使用邮政方法从这些页面中获取请求,但每个数据都有不同的序列序列号码
转到有效载荷,每个页面都有与我刮擦多个页面的序列号不同,因为每个数据都有不同的序列号
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论