如何抓取Facebook页面的

如何抓取Facebook页面的

本文介绍了如何抓取Facebook页面的“关于"部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 Facebook关于部分中抓取页面.我可以使用 Facebook Graph API ,还是我应该使用er ?" rel ="nofollow noreferrer">美丽的汤?

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?

推荐答案

Facebook Graph API用于用于读写Facebook社交图谱的应用程序" ,因此在这种情况下您将无法使用它.相反,您应使用 beautifulsoup 之类的Python抓取库.

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.

为组织任务声明刮取Facebook About页面的示例可能看起来像这样:

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.

这篇关于如何抓取Facebook页面的“关于"部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 21:24