How do I scrape the about section of a Facebook pa

2019-09-22 02:44发布

How do I scrape pages from the Facebook About section. Can I use Facebook Graph API or should I use a Python web-scraping library like Scrappy of Beautiful Soup?

1条回答
Deceive 欺骗
2楼-- · 2019-09-22 03:07

The Facebook Graph API is for "apps to read and write to the Facebook social graph" so you cannot use it in this case. Instead, you should use a Python scraping-libary like beautifulsoup.

An example of scraping the Facebook About Page for the organizations mission statement might look like this:

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.
查看更多
登录 后发表回答