python - 为什么当我运行 `sel` 时,选择器 `scrapy shell` 不存在?

标签 python scrapy

我从项目的顶级目录运行了scrapy shell myurl。下面是日志输出:

$ scrapy shell "http://www.aufeminin.com/forum/show0_3/grossesse.html"
2013-11-07 12:02:08+0100 [scrapy] INFO: Scrapy 0.14.4 started (bot: auf)
2013-11-07 12:02:08+0100 [scrapy] DEBUG: Enabled extensions: TelnetConsole, CloseSpider, WebService, CoreStats, MemoryUsage, SpiderState
2013-11-07 12:02:09+0100 [scrapy] DEBUG: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, RedirectMiddleware, CookiesMiddleware, HttpCompressionMiddleware, ChunkedTransferMiddleware, DownloaderStats
2013-11-07 12:02:09+0100 [scrapy] DEBUG: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2013-11-07 12:02:09+0100 [scrapy] DEBUG: Enabled item pipelines: 
2013-11-07 12:02:09+0100 [scrapy] DEBUG: Telnet console listening on 0.0.0.0:6023
2013-11-07 12:02:09+0100 [scrapy] DEBUG: Web service listening on 0.0.0.0:6080
2013-11-07 12:02:09+0100 [AufemininKeywordClassifierSpider] INFO: Spider opened
2013-11-07 12:02:09+0100 [AufemininKeywordClassifierSpider] DEBUG: Crawled (200) <GET http://www.aufeminin.com/forum/show0_3/grossesse.html> (referer: None)
[s] Available Scrapy objects:
[s]   hxs        <HtmlXPathSelector xpath=None data=u'<html>\r\n<head>\r\n<title>Forum Grossesse -'>
[s]   item       {}
[s]   request    <GET http://www.aufeminin.com/forum/show0_3/grossesse.html>
[s]   response   <200 http://www.aufeminin.com/forum/show0_3/grossesse.html>
[s]   settings   <CrawlerSettings module=<module 'auf.settings' from '/home/louist/Desktop/auf/auf/settings.pyc'>>
[s]   spider     <AufKeywordSpider 'AufemininKeywordClassifierSpider' at 0x3d41ed0>
[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

教程建议我应该有一个名为 sel 的变量,其中包含一个选择器。为什么情况并非如此?

最佳答案

hxs 包含您案例中的选择器。

关于python - 为什么当我运行 `sel` 时,选择器 `scrapy shell` 不存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19834296/

相关文章:

python - 如何创建一个临时目录并获取其路径/文件名?

Python检查列表中的任何元素是否是字典中的键

python - 使用PyInstaller将.py和.txt文件封装成.exe文件

django - 将信息从 Scrapy 爬虫持续导出到 Django 应用程序数据库的最佳方法是什么?

python - Scrapy从表中的链接获取数据

python - Scrapy 蜘蛛在设置 'start_urls' 变量后不会产生 feed 输出

python - 乘以一元素矩阵

python - PEP8 是否建议从方法返回变量或函数调用?

Python:scrapy教程,导入错误没有名为pywintypes的模块

python - 从 Scrapy 输出中删除文本的代码