brutalsavage / facebook-post-scraper

Facebook Post Scraper 🕵️🖱️
GNU General Public License v3.0
324 stars 116 forks source link

KeyError: 'data-testid' #23

Open latifaait opened 4 years ago

latifaait commented 4 years ago

Hello, Thank you for the post of Facebook-post-scraper I have done all the requirements, but when I run this code :

import argparse import time import json import csv

from selenium import webdriver from selenium.webdriver.chrome.options import Options from bs4 import BeautifulSoup as bs

from scraper import extract

list = extract("ministere.sante.ma", 1 )

=============================== and I got thhis error :

Number Of Scrolls Needed 0 in shares

KeyError Traceback (most recent call last)

in 10 from scraper import extract 11 ---> 12 list = extract("ministere.sante.ma", 1 ) ~\Desktop\PFE\PFE-GIT\scraper.py in extract(page, numOfPost, infinite_scroll, scrape_comment) 207 bs_data = bs(source_data, 'html.parser') 208 --> 209 postBigDict = _extract_html(bs_data) 210 browser.close() 211 ~\Desktop\PFE\PFE-GIT\scraper.py in _extract_html(bs_data) 98 for toolBar_child in toolBar[0].children: 99 --> 100 str = toolBar_child['data-testid'] 101 reaction = str.split("UFI2TopReactions/tooltip_")[1] 102 C:\ProgramData\Anaconda3\lib\site-packages\bs4\element.py in __getitem__(self, key) 969 """tag[key] returns the value of the 'key' attribute for the tag, 970 and throws an exception if it's not there.""" --> 971 return self.attrs[key] 972 973 def __iter__(self): KeyError: 'data-testid'