brutalsavage/facebook-post-scraper

Facebook New Design

krawez opened this issue · 2 comments

Facebook has updated its layout, so all the parsing has to be reviewed :(

Did you manage to fix it ?
Thank you

Here are a couple html codes for parsing I found so far (I am using Selenium, but can easily be updated to BeatifulSoup):

  • Posts:
    driver.find_elements_by_xpath("//div[@data-testid='Keycommand_wrapper_feed_story']/div[@data-testid='Keycommand_wrapper']/div[@ROLE='article']"

  • Post_text:
    post.find_element(By.CSS_SELECTOR,"div[data-ad-comet-preview='message']")

  • Reactions (Top 3):
    reactions = post.find_element_by_css_selector("span[role='toolbar']").find_elements_by_css_selector("div[role='button']")
    for reaction in reactions:
    reaction = reaction.get_attribute("aria-label")

I am struggling to extract the date - if someone has the solution - would love to hear!