Application versioning:
Python: v3.5.4
Hello and good day!
I'm trying to scrape Facebook posts and fetch the number of comments a post has with the following code:
from selenium import webdriver from bs4 import BeautifulSoup from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait # Omitted some codes here # To summarize, the codes above let me log in to my dummy account in Facebook # Codes above tested if there's an existing cookie, or a new log-in instance, then refresh to FB fb = webdriver.Firefox() fb.get("https://www.facebook.com/") fb.get(url) comments = fb.find_elements_by_xpath('//div[@data-testid="fbFeedStoryUFI/feedbackSummary"]') print(comments) But when I run my python script it is telling me this:
expected string or bytes-like object Formerly, I was able to scrape the number of reactions a post has with this code:
reactions = fb.find_element_by_xpath('//span[@data-testid="UFI2ReactionsCount/sentenceWithSocialContext"]').click() modal = fb.find_element_by_xpath('//ul[@defaultactivetabkey="all"]').get_attribute('innerHTML') soup = BeautifulSoup(modal, 'html.parser') And there were no errors, am I doing something wrong here? I would like to thank you in advance for those who can help me :)