Python 为什么我的汤是空的?
我正在尝试获取class='profile-search-school-link'的所有URL,但甚至无法获取soup对象 我做了以下工作: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
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
#打印语句
[]我那令人沮丧的空汤
我不知道你的情况,但对我来说,链接断了——这可能是你的第一个问题;) 我得到一个错误代码
500
响应
嗯,所以在我第一次转到基本url而没有?开始时,它就起作用了 啊,我想这是因为在你第一次访问网站后,它会在你的本地存储中存储一些东西,例如cookies。除非启用cookies,否则Beauty Soup无法做到这一点;)
我建议使用它也不会加载到我的电脑上。你能把/?start=15取下吗。那对我来说就行了。