Import Error

0 Arnab Banerjee · December 14, 2014
What is the problem in the code, it says no such module name request.



import request
from bs4 import BeautifulSoup
import operator

def start(url):
    word = []
    source_code = requests.get(url).text
    soup = BeautifulSoup(source_code)
    for text in soup.find_all('a',{'class="post-title"'}):
        content = text.string
        word = content.lower().split()
        for each_word in word:
            print(each_word)
            word.append(each_word)
start('https://www.thenewboston.com/forum/')

Post a Reply

Replies

Oldest  Newest  Rating
+1 Bernard Pyc0d333 Parah · December 14, 2014
on terminla run:
$ sudo pip install requests
0 Arnab Banerjee · December 14, 2014
Yes, thanks bro, I did that few moments earlier, now my code is working, but it's printing infinite number of words which is not stopping, any solution to that. ??/
0 Bernard Pyc0d333 Parah · December 14, 2014
I think you should just send the data to a file instead.
you can just create a variable to get all the content and store in a file
  • 1

Python

107,217 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator