Skip to content

Instantly share code, notes, and snippets.

@chiaoyaaaaa
Last active September 12, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiaoyaaaaa/7709c90771e2fa62931364fc2b88d50f to your computer and use it in GitHub Desktop.
Save chiaoyaaaaa/7709c90771e2fa62931364fc2b88d50f to your computer and use it in GitHub Desktop.
catch fb first post's number of likes
from bs4 import BeautifulSoup
# 前面解釋過的,抓取所有貼文
soup = Soup(driver.page_source, "lxml")
frames = soup.find_all(class_='du4w35lb k4urcfbm l9j0dhe7 sjgh65i0')
# 抓取第一篇的按讚數
# find()裡面要先放'span'標籤再放class name
# frames[0]為第一篇貼文
# .text為抓取文字內容
# class name可能會修改,需要定期偵錯!
like = frames[0].find('span',class_="gpro0wi8 pcp91wgn").text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment