我正在尝试在 python 中使用 web-Crawler 来打印 facebook 推荐者的数量。例如,在天空新闻(http://news.sky.com/story/1330046/are-putins-little-green-men-back-in-ukraine)的这篇文章中,大约有 60 个 facebook 推荐。我想用 web-crawler 在 python 程序中打印这个数字。我试图这样做,但它不打印任何东西:
import requests
from bs4 import BeautifulSoup
def get_single_item_data(item_url):
source_code = requests.get(item_url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
# if you want to gather information from that page
for item_name in soup.findAll('span', {'class': 'pluginCountTextDisconnected'}):
try:
print(item_name.string)
except:
print("error")
get_single_item_data("http://news.sky.com/story/1330046/are-putins-little-green-men-back-in-ukraine")