taga
taga

Reputation: 3885

Scraping facebook likes, comments and shares with Beautiful Soup

I want to scrape number of likes, comments and shares with Beautiful soup and Python. I have wrote a code, but it returns me the empty list, I do not know why:

this is the code:

from bs4 import BeautifulSoup
import requests


website = "https://www.facebook.com/nike"

soup = requests.get(website).text
my_html = BeautifulSoup(soup, 'lxml')


list_of_likes = my_html.find_all('span', class_='_81hb')
print(list_of_likes)

for i in list_of_likes:
    print(i)

The same is with comments and likes. What should I do?

Upvotes: 0

Views: 1486

Answers (2)

Dmitry Leiko
Dmitry Leiko

Reputation: 4392

Probably, you can try use the Selenium.

Upvotes: 0

L. Letovanec
L. Letovanec

Reputation: 615

Facebook uses client side rendering...that means in the HTML document that you get and you have it stored in soup variable is just javascript code that actually renders the content only when you display it in browser.

Upvotes: 1

Related Questions