<分区> 分区>
我正在自学 Python,方法是实践而不是阅读。 当我运行这段代码时,终端没有显示错误,但什么也没有发生,尽管在我看来这应该是从这个列表中检索地址。
我调用这些数据的方式有问题吗?
import requests
from bs4 import BeautifulSoup
url = ("http://www.gym-directory.com/listing/bulldog-gym/")
r = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser")
print soup.prettify()
listing_data = soup.find_all("div", {"class":"tab-contents"})
for item in listing_data:
print item.contents[0].find_all("span",{"class":"wlt_shortcode_map_location"})[0].text




