kevinzg / facebook-scraper

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

I am geting only one post data only ,HOw can i get the all posts details of given urls #1093

Open kumarlova opened 8 months ago

kumarlova commented 8 months ago

listposts = [] MAX_COMMENTS=100

for post in get_posts("nintendo", pages=2):

posts = get_posts(post_urls=["https://www.facebook.com/britishairways","https://www.facebook.com/jemeeluAnna.Followers"],extra_info=True,credentials=('',''), options={"comments": MAX_COMMENTS, "progress": True})

for post in posts:

if isinstance(post, dict):
    # Print post on the screen
    print(post)
    print(json.dumps(post, indent=2, default=str))
    for x in post:
        print(x, post[x])
    # Print json object to file one object/post per line
    with open('fb.json', 'a', encoding='utf-8') as f:
        json.dump(post, f, ensure_ascii=False, default=str)
        f.write("\n")
    print(post.get('post_text', 'No post text available'))
    for cmt in post.get('comments_full', []):
        print(cmt.get('commenter_name', ''), " : ", cmt.get('comment_text', '').replace("\n", ""))
else:
    print("Post is not a dictionary:", post)