Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.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 为什么我的汤是空的?_Python_Html_Parsing_Beautifulsoup - Fatal编程技术网

Python 为什么我的汤是空的?

Python 为什么我的汤是空的?,python,html,parsing,beautifulsoup,Python,Html,Parsing,Beautifulsoup,我正在尝试获取class='profile-search-school-link'的所有URL,但甚至无法获取soup对象 我做了以下工作: site = "http://www.geteducated.com/profiles/search/Computer%20Science%20%26%20IT&SS=Search%20by%20Subject%20%3E%20Computer%20Science%20%26%20IT/?start=15" """ gets a list of

我正在尝试获取class='profile-search-school-link'的所有URL,但甚至无法获取soup对象

我做了以下工作:

site = "http://www.geteducated.com/profiles/search/Computer%20Science%20%26%20IT&SS=Search%20by%20Subject%20%3E%20Computer%20Science%20%26%20IT/?start=15"

""" gets a list of the urls for the degree programs """
r = requests.get(site)
html_source = r.text
soup = BeautifulSoup(html_source)

print(soup.prettify())
输出:

<class 'bs4.BeautifulSoup'> # print statement
[] # my depressingly empty soup
#打印语句
[]我那令人沮丧的空汤
  • 代码是怎么回事?粘贴到浏览器中时链接未断开

  • 如何获取URL


  • 我不知道你的情况,但对我来说,链接断了——这可能是你的第一个问题;)

    我得到一个错误代码500响应


    嗯,所以在我第一次转到基本url而没有?开始时,它就起作用了

    啊,我想这是因为在你第一次访问网站后,它会在你的本地存储中存储一些东西,例如cookies。除非启用cookies,否则Beauty Soup无法做到这一点;)


    我建议使用

    它也不会加载到我的电脑上。你能把/?start=15取下吗。那对我来说就行了。