gpt4 book ai didi

python - 错误: Error while obtaining start requests - Scrapy

转载 作者:太空宇宙 更新时间:2023-11-03 17:11:48 24 4
gpt4 key购买 nike

当我运行下面的代码时,出现以下错误:http://pastebin.com/AJqRxCpM我的设置:http://pastebin.com/9nzaXLJs

这是我的代码:

import scrapy

import requests
from scrapy.http import Request

import scrapy
from FinalSpider.items import Page # Defined in items.py

URL = "http://url.com/PopUp.aspx?IDCoupon=%d"
starting_number = 60000
number_of_pages = 80

class FinalSpider(scrapy.Spider):
name = "FinalSpider"
allowed_domains = ['url.com']
start_urls = [URL % starting_number]

def __init__(self):
self.page_number = starting_number

def start_requests(self):
for i in range (self.page_number, number_of_pages, -1):
yield request(url = URL % i, callback=self.parse)

def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename, 'wb') as f:
f.write(response.body)

最佳答案

已经解决了。只需添加以下内容:

start_urls = ['url.com/=%d' %(n)
for n in range(0, 20)] * MEANS from 0 to 20

关于python - 错误: Error while obtaining start requests - Scrapy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34006420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com