如何在Facebook页面上刮取about部分?

2024-06-02 06:01:04 发布

您现在位置:Python中文网/ 问答频道 /正文

{我怎么从书页上刮下来。我可以使用Facebook Graph API还是应该使用像Scrappy或{a4}的Scrappy这样的Python web抓取库?在


Tags: apiwebfacebookgrapha4scrappy书页
1条回答
网友
1楼 · 发布于 2024-06-02 06:01:04

Facebook图形API用于"apps to read and write to the Facebook social graph",因此在本例中不能使用它。相反,应该使用Python抓取库,比如beautifulsoup。在

在Facebook上为组织的使命声明创建About页面的例子如下:

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.

相关问题 更多 >