要从Facebook MBasic版本中抓取story_id(故事ID),你需要使用Web抓取技术,例如Python的BeautifulSoup库
pip install beautifulsoup4
pip install requests
import requests
from bs4 import BeautifulSoup
# 替换以下URL为你想抓取的MBasic Facebook页面
url = "https://mbasic.facebook.com/story.php?story_fbid=..."
response = requests.get(url)
if response.status_code == 200:
html_content = response.text
else:
print("Error fetching the URL:", response.status_code)
soup = BeautifulSoup(html_content, "html.parser")
# 根据HTML结构,你可以使用CSS选择器或find方法寻找包含story_id的元素
# 以下示例使用CSS选择器:
story_id_element = soup.select_one("div[data-story-id]")
if story_id_element:
story_id = story_id_element["data-story-id"]
print("Story ID:", story_id)
else:
print("Story ID not found")
注意:Facebook可能会更新页面结构和元素,导致代码无法正常运行。此时,你需要检查页面源代码并相应地调整选择器和属性。
警告:
领取专属 10元无门槛券
手把手带您无忧上云