0
我想從版權政府網站使用scrapy獲取數據。這是我的蜘蛛:如何獲得scrapy FormRequest的工作
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.http import FormRequest, Request
from scrapy.utils.response import open_in_browser
class CopyrightSpider(BaseSpider):
name = "copyright_records"
start_url = ["http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?DB=local&PAGE=First"]
def parse(self, response):
yield FormRequest.from_response(response,
formname='querybox',
formdata={'Search_Arg': 'walt disney', 'Search_Code': 'Command Keyword'},
callback=self.parse1)
def parse1(self, response):
open_in_browser(response)
運行履帶然而,當我看到0的頁面被抓取我不明白的錯誤:
2015-03-30 15:01:08-0700 [scrapy] INFO: Scrapy 0.24.5 started (bot: copyright_records)
2015-03-30 15:01:08-0700 [scrapy] INFO: Optional features available: ssl, http11
2015-03-30 15:01:08-0700 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'copyright_records.spiders', 'SPIDER_MODULES': ['copyright_records.spiders'], 'BOT_NAME': 'copyright_records'}
2015-03-30 15:01:08-0700 [scrapy] INFO: Enabled extensions: LogStats, TelnetConsole, CloseSpider, WebService, CoreStats, SpiderState
2015-03-30 15:01:08-0700 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2015-03-30 15:01:08-0700 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2015-03-30 15:01:08-0700 [scrapy] INFO: Enabled item pipelines:
2015-03-30 15:01:08-0700 [copyright_records] INFO: Spider opened
2015-03-30 15:01:08-0700 [copyright_records] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-03-30 15:01:08-0700 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2015-03-30 15:01:08-0700 [scrapy] DEBUG: Web service listening on 127.0.0.1:6080
2015-03-30 15:01:08-0700 [copyright_records] INFO: Closing spider (finished)
2015-03-30 15:01:08-0700 [copyright_records] INFO: Dumping Scrapy stats:
{'finish_reason': 'finished',
'finish_time': datetime.datetime(2015, 3, 30, 22, 1, 8, 867056),
'log_count/DEBUG': 2,
'log_count/INFO': 7,
'start_time': datetime.datetime(2015, 3, 30, 22, 1, 8, 865055)}
2015-03-30 15:01:08-0700 [copyright_records] INFO: Spider closed (finished)
不知道爲什麼它不工作,任何幫助將不勝感激, 謝謝!
的感謝!它現在的工作 – daphweg 2015-03-31 05:55:57
我試圖從2015年獲得所有音樂記錄,但是當我進行廣泛搜索時,網站超時如何解決這個問題? – daphweg 2015-03-31 06:06:52
@daphweg如果你有困難,請考慮創建一個新問題 - 這樣至少有更多的人可以有機會幫助你。謝謝你的理解。 – alecxe 2015-03-31 14:46:04