Python 程序读取多个URL并生成一个单词(应仅包含字母数字)频率表

Python 程序读取多个URL并生成一个单词(应仅包含字母数字)频率表,python,Python,我正在编写一个Python程序来读取多个URL并生成一个单词(一个单词只包含字母a-Za-z0-9)频率表。输出可以存储在名为url1.txt、url2.txt的文件中 这就是我到目前为止所做的: import urllib2 import obo url = 'sample url' response = urllib2.urlopen(url) html = response.read() text = obo.stripTags(html).lower() wordlist = obo

我正在编写一个Python程序来读取多个URL并生成一个单词(一个单词只包含字母a-Za-z0-9)频率表。输出可以存储在名为url1.txt、url2.txt的文件中

这就是我到目前为止所做的:

import urllib2
import obo

url = 'sample url'

response = urllib2.urlopen(url)
html = response.read()
text = obo.stripTags(html).lower()
wordlist = obo.stripNonAlphaNum(text)


for s in sorteddict: 
    print str(s)

您可以使用样板文件轻松提取文本:

代码可能如下所示:

from boilerpipe.extract import Extractor
from collections import Counter

urls = ['url1', 'url2', ... ] # A list of the urls you want to fetch
# Ask boilerpipe to fetch the data
extractors = [Extractor(extractor='ArticleExtractor', url=url) for url in urls]
# Ask boilerpipe to extract the text
raw_texts = [extractor.getText() for extractor in extractors]
# count the occurrences of words in each text
word_counts = [Counter(text.split(" ")) for text in raw_texts]

你的问题是…?如何进一步?遵循user3091275步骤,但看到导入错误吗?谢谢,但当我运行此操作时。我看到以下错误。回溯(最后一次调用):文件“test0731.py”,第1行,从boilerpipe.extract导入提取器文件“/Library/Python/2.7/site packages/boilerpipe/extract/__init___;.py”,第4行,在import charade ImportError中:没有名为charade的模块我已确保charade软件包已导入您是否使用
sudo pip install boilerpipe安装了boilerpipe
?是的,安装正确并显示成功?就我而言,我只需使用pip安装模块,导入没有问题。尝试重新安装该软件包,它应该带有猜字谜。