我打开scrapy shell如下
scrapy shell "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/"
这给了我:
[s] Available Scrapy objects:
[s] hxs <HtmlXPathSelector xpath=None data=u'<html><head><meta http-equiv="Content-Ty'>
[s] item {}
[s] request <GET http://www.dmoz.org/Computers/Programming/Languages/Python/Books/>
[s] response <200 http://www.dmoz.org/Computers/Programming/Languages/Python/Books/>
[s] settings <CrawlerSettings module=None>
[s] spider <BaseSpider 'default' at 0x9e1d3ec>
[s] Useful shortcuts:
[s] shelp() Shell help (print this help)
[s] fetch(req_or_url) Fetch request (or URL) and update local objects
[s] view(response) View response in a browser
In [1]: hxs.select('//title')
Out[1]: [<HtmlXPathSelector xpath='//title' data=u'<title>Open Directory - Computers: Progr'>]
响应的标题与预期的一样:
In [1]: hxs.select('//title')
Out[1]: [<HtmlXPathSelector xpath='//title' data=u'<title>Open Directory - Computers: Progr'>]
现在我用一个简单的 fetch 来跟进:
In [2]: fetch("http://www.google.com")
shell 输出表明对象已更新:
In [2]: fetch("http://www.google.com")
2013-10-18 23:10:09+0530 [default] DEBUG: Redirecting (302) to <GET http://www.google.co.in/?gws_rd=cr&ei=eHJhUo2sOobSrQeM5ICAAg> from <GET http://www.google.com>
2013-10-18 23:10:09+0530 [default] DEBUG: Crawled (200) <GET http://www.google.co.in/?gws_rd=cr&ei=eHJhUo2sOobSrQeM5ICAAg> (referer: None)
[s] Available Scrapy objects:
[s] hxs <HtmlXPathSelector xpath=None data=u'<html itemscope="" itemtype="http://sche'>
[s] item {}
[s] request <GET http://www.google.com>
[s] response <200 http://www.google.co.in/?gws_rd=cr&ei=eHJhUo2sOobSrQeM5ICAAg>
[s] settings <CrawlerSettings module=None>
[s] spider <BaseSpider 'default' at 0x9e1d3ec>
[s] Useful shortcuts:
[s] shelp() Shell help (print this help)
[s] fetch(req_or_url) Fetch request (or URL) and update local objects
[s] view(response) View response in a browser
但是,我发现他们没有。view(response) 显示 dmoz 页面
并提取标题给出相同的旧标题:
In [3]: hxs.select('//title')
Out[3]: [<HtmlXPathSelector xpath='//title' data=u'<title>Open Directory - Computers: Progr'>]
我在这里想念什么?
谢谢!