2011-09-11 69 views

回答

4

http://dev.scrapy.org/wiki/ScrapyRecipes

如何僞造請求是HTTP 1.1兼容 您可以通過重寫Scrapy HTTP客戶端廠,用下面的(無證)爲此設置:

DOWNLOADER_HTTPCLIENTFACTORY = 'myproject.downloader.HTTPClientFactory' 

這裏有一個myproject.downloader模塊的可能實現:

from scrapy.core.downloader.webclient import ScrapyHTTPClientFactory, ScrapyHTTPPageGetter 

class PageGetter(ScrapyHTTPPageGetter): 

    def sendCommand(self, command, path): 
     self.transport.write('%s %s HTTP/1.1\r\n' % (command, path)) 

class HTTPClientFactory(ScrapyHTTPClientFactory): 

    protocol = PageGetter   
+0

這是有效的。謝謝。 – user891260