为什么我的汤是空的?

2024-04-26 00:04:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试获取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
  1. 代码是怎么回事?当我粘贴到浏览器中时链接没有断开。

  2. 如何获取URL?


Tags: the对象httpurlsourcesearchhtmllink
1条回答
网友
1楼 · 发布于 2024-04-26 00:04:51

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

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


嗯,在我第一次访问基本url而不使用?开始。你知道吗

啊,我想这是因为你第一次去网站后,它会把东西存储在你本地的存储库里,比如饼干。除非启用cookies,否则Beautiful Soup无法做到这一点;)

我建议使用CookieLib

相关问题 更多 >