Last active
September 12, 2020 13:43
-
-
Save chiaoyaaaaa/7709c90771e2fa62931364fc2b88d50f to your computer and use it in GitHub Desktop.
catch fb first post's number of likes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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