我正在研究如何在youtube上找到的webscrape的示例,并逐步完成它。 https://www.youtube.com/watch?v=3xQTJi2tqgk 这是我的代码和我不断得到的错误。
import requests
from bs4 import BeautifulSoup
url = ('http://www.yellowpages.com/search?search_terms=coffee&geo_location_terms=Los+Angeles%2C+CA')
r = requests.get(url)
soup = BeautifulSoup(r.content)
links = soup.find_all("a")
for link in links:
print "<a href='%s'>%s</a>" %(link.get("href"), link.text)
g_data = soup.find_all("div", {"class": "info"})
print g_data
ERROR
Traceback (most recent call last):
line 8, in <module>
soup = BeautifulSoup(r.content)
TypeError: __init__() takes at least 5 arguments (2 given)
我曾尝试在其他文件上使用汤模块,但它仍然无法正常工作。有任何想法吗?提前谢谢!