如何抓取Facebook页面的大概部分?

时间:2017-10-22 20:45:02

标签: python facebook web-scraping

如何从Facebook About section抓取页面。我可以使用Facebook Graph API还是应该使用像ScrappyBeautiful Soup这样的Python网页抓取库?

1 个答案:

答案 0 :(得分:1)

Facebook Graph API适用于"apps to read and write to the Facebook social graph",因此在这种情况下您无法使用它。相反,您应该使用像beautifulsoup这样的Python抓取库。

为组织任务声明抓取Facebook关于页面的示例可能如下所示:

from bs4 import BeautifulSoup
import requests

response = requests.get("https://www.facebook.com/pg/officialstackoverflow/about/?ref=page_internal")
html = response.content
soup = BeautifulSoup(html, "html")
mission_statement = soup.find('div', attrs={'class': '_3-8w'})
print(mission_statement.text)
> To make the internet a better place and be the best site to find expert answers to your programming questions.