在terminal中输入
scrapy shel
随后再>>> 输入
headers= {‘host’:‘1’}
req = scrapy.Request(url=‘https://www.guazi.com/cd/buy/’,headers=headers)
fetch(req)
terminal具体显示结果如下:
[s] Available Scrapy objects:
[s] scrapy scrapy module (contains scrapy.Request, scrapy.Selector, etc)
[s] crawler <scrapy.crawler.Crawler object at 0x107fac748>
[s] item {}
[s] settings <scrapy.settings.Settings object at 0x107fac978>
[s] Useful shortcuts:
[s] fetch(url[, redirect=True]) Fetch URL and update local objects (by default, redirects are followed)
[s] fetch(req) Fetch a scrapy.Request and update local objects
[s] shelp() Shell help (print this help)
[s] view(response) View response in a browser
headers = {‘user-agent’:’‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36’
',‘host’:‘1’
}
req = scrapy.Request(url=‘https://www.guazi.com/cd/buy/’,headers=headers)
fetch(req)
2019-03-19 14:11:31 [scrapy.core.engine] INFO: Spider opened
2019-03-19 14:11:34 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.guazi.com/cd/buy/> (referer: None)