Skip to content

Instantly share code, notes, and snippets.

@chiaoyaaaaa
Created September 13, 2020 03:37
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/437fbff9cb8c6f2fef3bb3a6d94c0a3f to your computer and use it in GitHub Desktop.
Save chiaoyaaaaa/437fbff9cb8c6f2fef3bb3a6d94c0a3f to your computer and use it in GitHub Desktop.
catch fb all post's number of shares
# 建立一個空的list
share = []
# 抓取每一篇貼文的分享數
# find_all() 後面要加上 [1] 才能取出分享數
# class name可能會修改,需要定期偵錯!
for ii in frames:
read = ii.find_all('span',class_="oi732d6d ik7dh3pa d2edcug0 hpfvmrgz qv66sw1b c1et5uql a8c37x1j muag1w35 enqfppq2 jq4qci2q a3bd9o3v knj5qynh m9osqain")[1]
# 有些貼文沒有分享數,所以抓下來的東西是None,因此直接append 0
if(read == None):
share.append('0次')
else:
share.append(read.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment