Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python “什么是”呢;类型错误:';dict';对象不可调用";?_Python - Fatal编程技术网

Python “什么是”呢;类型错误:';dict';对象不可调用";?

Python “什么是”呢;类型错误:';dict';对象不可调用";?,python,Python,我正在处理网页抓取,但是代码显示了一个错误。我怎样才能解决这个问题 我已经安装了与BeautifulSoup相关的所有必需软件包 import request from bs4 import BeautifulSoup page = request.GET('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)') soup = BeautifulSoup(page.content, 'html.parser') print

我正在处理网页抓取,但是代码显示了一个错误。我怎样才能解决这个问题

我已经安装了与BeautifulSoup相关的所有必需软件包

import request
from bs4 import BeautifulSoup

page = request.GET('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
soup = BeautifulSoup(page.content, 'html.parser')

print(soup)
我期望网站的HTML,但它显示:

page = request.GET('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
TypeError: 'dict' object is not callable

我认为代码应该是

import requests
from bs4 import BeautifulSoup
page = requests.get('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
soup = BeautifulSoup(page.content,'html.parser')

print(soup)
至少在我这方面是可行的(Python 3.6)

正如注释中所建议的那样,
requests
是用于http调用的Python规范包,
request
Flask
中用于访问http调用参数的子包

import requests
from bs4 import BeautifulSoup

page = requests.get('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
soup = BeautifulSoup(page.content, 'html.parser')
page = soup.prettify()
print(page)
requests
是用于HTTP调用的Python规范包,并且


request
是Flask中访问HTTP调用参数的子包。

首先,什么是
request
?这是
请求
的打字错误还是另一个包?
请求
是一个烧瓶子包,您需要
请求
,带有s
import requests
from bs4 import BeautifulSoup

page = requests.get('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
soup = BeautifulSoup(page.content, 'html.parser')
page = soup.prettify()
print(page)