Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.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 为什么可以';我在BeautifulSoup文档中没有找到关于.text或content方法的任何内容吗?_Python_Beautifulsoup_Documentation - Fatal编程技术网

Python 为什么可以';我在BeautifulSoup文档中没有找到关于.text或content方法的任何内容吗?

Python 为什么可以';我在BeautifulSoup文档中没有找到关于.text或content方法的任何内容吗?,python,beautifulsoup,documentation,Python,Beautifulsoup,Documentation,目前,我正在学习Udemy上的Python课程,我正在学习web抓取的概念。具体做法如下: import requests import bs4 url = requests.get("http://example.com/") soup = bs4.BeautifulSoup(url.text, "lxml") 现在,我在文档中找不到关于Beautifulsoup的文本方法的任何内容。我知道这一点,因为我在下面的课程中已经清楚地解释了这一点 这正常吗

目前,我正在学习Udemy上的Python课程,我正在学习web抓取的概念。具体做法如下:

import requests
import bs4

url = requests.get("http://example.com/")
soup = bs4.BeautifulSoup(url.text, "lxml")
现在,我在文档中找不到关于Beautifulsoup的文本方法的任何内容。我知道这一点,因为我在下面的课程中已经清楚地解释了这一点


这正常吗?在以后的文档中搜索相关信息时,我会从一般的角度对此进行更多的询问。

您必须使用.text属性,因为如果在您的案例中仅使用url,您只能获得请求的状态码,它不能是soup对象中的参数。

因为这是来自请求库中对象的属性,所以它只是BeautifulSoup的输入。看,谢谢!直到现在我才完全明白。谢谢!我得到了错误TypeError:“Response”类型的对象没有len(),但这解释了为什么我会得到它。