kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.45k stars 633 forks source link

cant set cookies #1124

Open rakage opened 3 days ago

rakage commented 3 days ago

Hi, i have a cookie that extracted from CookieManager, but i got error Requesting page from: https://m.facebook.com/pfbid037tBZ7KYfHSacfqGdbmK6tXu78RUYHp2L31K4A9rCcewHNL53ERSuEaFkDJZFuwjFl No raw posts (

elements) were found in this page. Error scraping comments for https://www.facebook.com/photo.php?fbid=950799983744725&set=pb.100064441971374.-2207520000&type=3: 'time'

" try: set_noscript(True) set_cookies('exported-cookies.json') enable_logging() data = get_posts(

post_urls=[bank_url],

        post_urls=['pfbid037tBZ7KYfHSacfqGdbmK6tXu78RUYHp2L31K4A9rCcewHNL53ERSuEaFkDJZFuwjFl'],
        options={"comments": 10000, "progress": True},
        # cookies='exported-cookies.json'
    )
    post = next(data)
    post_date = post['time']
    comments = post['comments_full']
    komen = []
    balasan = []
    for comment in comments:
        if len(comment['replies']) > 0:
            for reply in comment['replies']:
                balasan.append({
                    'url': bank_url,
                    'post_date': post_date,
                    'name': reply['commenter_name'],
                    'comments': reply['comment_text'],
                    'comments_date': reply['comment_time'],
                    'bank': bank_name,
                    'platform': 'Facebook'
                })
        else:
            komen.append({
                'url': bank_url,
                'post_date': post_date,
                'name': comment['commenter_name'],
                'comments': comment['comment_text'],
                'comments_date': comment['comment_time'],
                'bank': bank_name,
                'platform': 'Facebook'
            })

    data_comments.extend(komen)
    data_comments.extend(balasan)
    # time.sleep(5)
except Exception as e:
    print(f"Error scraping comments for {bank_url}: {e}")

"