'module' object has no attribute 'get'?

Hironori Nakauchi
from urllib import request
from bs4 import BeautifulSoup
def trade_spider(max_pages):
page = 1
while page <= max_pages:
    x = 16958 + int(page)
    url = 'http://mery.jp/' + str(x)
    source_code = request.get(url)
    plain_text = source_code.text
    soup = BeautifulSoup(plain_text)
    print(soup)
    break

trade_spider(2)

when I try to run the code above in my Python3.4, I get an error that says the following:

File "web_crawler.py", line 15, in <module>
trade_spider(2)
File "web_crawler.py", line 9, in trade_spider
source_code = request.get(url)
AttributeError: 'module' object has no attribute 'get'

any ideas on how to fix this? Thank you in advance.

Andrew Z

You imported request from urllib, but urllib.request doesn't have a get method. I think you want to import the requests module and use requests.get in lieu of request.get. Either that or you want to replace get with urlopen. Considering that you reference the .text attribute in the next line, it probably is the former and not the latter.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

'module' object has no attribute 'get'?

From Dev

requests: 'module' object has no attribute 'get'

From Dev

Python AttributeError: 'module' object has no attribute 'get'

From Dev

AttributeError: 'module' object has no attribute 'get_altitude'

From Dev

Custom Module - Object Has No Attribute

From Dev

AttributeError: 'module' object has no attribute

From Dev

'module' object has no attribute 'Serial'

From Dev

'module' object has no attribute 'DataFrame'

From Dev

AttributeError: 'module' object has no attribute

From Dev

'module' object has no attribute 'GeoSQLCompiler'

From Dev

AttributeError: 'module' object has no attribute

From Dev

module object has no attribute oauth

From Dev

module' object has no attribute 'SelectDateWidget'

From Dev

'module' object has no attribute 'GeoSQLCompiler'

From Dev

'module' object has no attribute 'cut'

From Dev

'module' object has no attribute 'shortcuts'

From Dev

'module' object has no attribute 'TK'

From Dev

'unicode' object has no attribute 'get'

From Dev

'WSGIRequest' object has no attribute 'get'

From Dev

'list' object has no attribute 'get'

From Dev

'str' object has no attribute 'get'

From Dev

'ValidationError' object has no attribute 'get'

From Dev

AttributeError:'module' object has no attribute 'call' :Python

From Dev

Pylab - 'module' object has no attribute 'Figure'

From Dev

AttributeError: 'module' object has no attribute 'tk'

From Dev

AttributeError: 'module' object has no attribute 'cache'

From Java

AttributeError: 'module' object has no attribute 'tests'

From Dev

'module' object has no attribute 'views' django error

From Dev

AttributeError: 'module' object has no attribute 'TestCase'

Related Related

HotTag

Archive