-6

This is part of a code for text summarization using NLTK:

import urllib
feed_xml = urllib.urlopen('http://feeds.bbci.co.uk/news/rss.xml').read()
feed = BeautifulSoup(feed_xml.decode('utf8'))
to_summarize = map(lambda p: p.text, feed.find_all('guid'))
fs = FrequencySummarizer()
for article_url in to_summarize[:5]:
    title, text = get_only_text(article_url)
    print ('----------------------------------')
    print (title)
for s in fs.summarize(text, 2):
    print ('*',s)

Here is the error

C:\Python34>2.py
Traceback (most recent call last):
File "C:\Python34\2.py", line 2, in <module>
feed_xml = urllib.urlopen('http://feeds.bbci.co.uk/news/rss.xml').read()
AttributeError: 'module' object has no attribute 'urlopen'
halfer
  • 19,824
  • 17
  • 99
  • 186
  • What did you try until now to localize your error ? Show us your efforts. – Aracthor Apr 30 '15 at 07:31
  • 2
    In case you are wondering why your question is being downvoted: the most likely reasons are that your title is rather terrible (describe the problem itself, not that you have a problem, *all* questions ask for help), and the error message is trivially googleable, with the answer readily available for you had you searched. – Martijn Pieters Apr 30 '15 at 07:33

1 Answers1

1

Try urllib.request.urlopen() instead of urllib.urlopen()

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Avión
  • 7,963
  • 11
  • 64
  • 105