【问题标题】:Example of 'Programming Collective Intelligence' doesn't work“编程集体智慧”的例子不起作用
【发布时间】:2013-12-24 17:04:05
【问题描述】:

我从here 下载了源代码。我试图运行托比·塞加兰(Toby Segaran)的“编程集体智能”一书的第 4 章中的示例。我的python版本是2.7.2。我在解释器中输入这段代码:

import searchengine
pages=['http://en.wikipedia.org/wiki/Programming_language']
crawler = searchengine.crawler('searchindex.db')
crawler.crawl(pages)

并得到消息:

Could not open http://en.wikipedia.org/wiki/Programming_language

或者有时会收到消息:

Indexing http://en.wikipedia.org/wiki/Programming_language
Could not parse page http://en.wikipedia.org/wiki/Programming_language

总的来说,爬虫不会索引页面。我做错了什么?

【问题讨论】:

    标签: python search search-engine ranking


    【解决方案1】:

    def separateWords(self,text)大写的W转为小写,在gettextonly(self,soup)中,将v==Null转为None。您还必须执行后面的步骤,例如

    >> crawler=searchengine.crawler('searchindex.db') 
    >> crawler.createindextables()
    >> crawler=searchengine.crawler('searchindex.db') 
    

    首先,然后尝试运行page=['***'] 和其他步骤。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-18
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多