kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.29k stars 616 forks source link

reactors are none [Issue] #250

Closed fashan7 closed 3 years ago

fashan7 commented 3 years ago

I noticed that "reactors":"None", it seems only one reaction doesn't return, it returns only it has more than one reaction. for example, it should have like, haha, etc...

please check @neon-ninja

neon-ninja commented 3 years ago

What post are you having this problem with?

fashan7 commented 3 years ago

https://www.facebook.com/Voix.de.biskra/posts/3855820361202097 It gave me comments but not the reaction @neon-ninja please check

neon-ninja commented 3 years ago

This should fix it https://github.com/kevinzg/facebook-scraper/commit/fb17c1aee511640da9ef988d34337478e66db90d

fashan7 commented 3 years ago

what can be the issue? have any idea? @neon-ninja

neon-ninja commented 3 years ago

The HTML differs if there's only one type of reaction

fashan7 commented 3 years ago

ok cool, thanks @neon-ninja

fashan7 commented 3 years ago

@neon-ninja the issue still exists Giving same results of none

`{
   "post_id":"3855820361202097",
   "text":"من #رسائلكم\n#khaled",
   "post_text":"من #رسائلكم\n#khaled",
   "shared_text":"",
   "time":datetime.datetime(2021,
   5,
   11,
   0,
   14,
   57),
   "image":"https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&_nc_ohc=58vEoAlBjygAX9m_UF8&_nc_ht=scontent-lga3-1.xx&tp=14&oh=0e1fde028ecf99a228b72357f7f8e60b&oe=60C143A0",
   "image_lowquality":"https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p240x240/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&_nc_ohc=58vEoAlBjygAX9m_UF8&_nc_ht=scontent-lga3-1.xx&tp=3&oh=3f2c0c67e856c6919e25e8da1650cce4&oe=60BFDF35",
   "images":[
      "https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&_nc_ohc=58vEoAlBjygAX9m_UF8&_nc_ht=scontent-lga3-1.xx&tp=14&oh=0e1fde028ecf99a228b72357f7f8e60b&oe=60C143A0"
   ],
   "images_description":[
      "May be an image of \u200eone or more people and \u200etext that says '\u200eمساء الخير اخي ارجو ان تنشرو دون ذكر اسمي وجدت صورة ووصل استلام ملف تسجيل امتحان باكالوريا باسم طهراوي رميساء واريد ان اوصل لها امانتها باذن الله نشكرك على مراسلتنا نحن نسعى\u200e'\u200e\u200e"
   ],
   "images_lowquality":[
      "https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p240x240/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&_nc_ohc=58vEoAlBjygAX9m_UF8&_nc_ht=scontent-lga3-1.xx&tp=3&oh=3f2c0c67e856c6919e25e8da1650cce4&oe=60BFDF35"
   ],
   "images_lowquality_description":[
      "May be an image of \u200eone or more people and \u200etext that says '\u200eمساء الخير اخي ارجو ان تنشرو دون ذكر اسمي وجدت صورة ووصل استلام ملف تسجيل امتحان باكالوريا باسم طهراوي رميساء واريد ان اوصل لها امانتها باذن الله نشكرك على مراسلتنا نحن نسعى\u200e'\u200e\u200e"
   ],
   "video":"None",
   "video_duration_seconds":"None",
   "video_height":"None",
   "video_id":"None",
   "video_quality":"None",
   "video_size_MB":"None",
   "video_thumbnail":"None",
   "video_watches":"None",
   "video_width":"None",
   "likes":7,
   "comments":0,
   "shares":0,
   "post_url":"https://facebook.com/875365599247603/posts/3855820361202097",
   "link":"None",
   "user_id":"875365599247603",
   "username":"Voix de biskra صوت بسكرة",
   "user_url":"https://facebook.com/Voix.de.biskra/?__tn__=C-R",
   "is_live":false,
   "factcheck":"None",
   "shared_post_id":"None",
   "shared_time":"None",
   "shared_user_id":"None",
   "shared_username":"None",
   "shared_post_url":"None",
   "available":true,
   "comments_full":"None",
   "reactors":"None",
   "w3_fb_url":"None"
}`

Below Post has 2kinds of reactions. But still reactors are null

`{
   "post_id":"3855323311251802",
   "text":"من الصفحة الرسمية لفريق اتحاد بسكرة لكرة القدم\n#فلسطين",
   "post_text":"من الصفحة الرسمية لفريق اتحاد بسكرة لكرة القدم\n#فلسطين",
   "shared_text":"",
   "time":datetime.datetime(2021,
   5,
   10,
   20,
   0,
   51),
   "image":"https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&_nc_ohc=tUKoBsTDY-8AX93ib9G&_nc_ht=scontent-lga3-1.xx&tp=14&oh=f59b1e75a4e04264630b214b793482e1&oe=60BDE953",
   "image_lowquality":"https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p320x320/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&_nc_ohc=tUKoBsTDY-8AX93ib9G&_nc_ht=scontent-lga3-1.xx&tp=3&oh=9898cf5bd8ebad3c703fdcc8f1d5747b&oe=60C0BF17",
   "images":[
      "https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&_nc_ohc=tUKoBsTDY-8AX93ib9G&_nc_ht=scontent-lga3-1.xx&tp=14&oh=f59b1e75a4e04264630b214b793482e1&oe=60BDE953"
   ],
   "images_description":[
      "May be an image of text"
   ],
   "images_lowquality":[
      "https://scontent-lga3-1.xx.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p320x320/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&_nc_ohc=tUKoBsTDY-8AX93ib9G&_nc_ht=scontent-lga3-1.xx&tp=3&oh=9898cf5bd8ebad3c703fdcc8f1d5747b&oe=60C0BF17"
   ],
   "images_lowquality_description":[
      "May be an image of text"
   ],
   "video":"None",
   "video_duration_seconds":"None",
   "video_height":"None",
   "video_id":"None",
   "video_quality":"None",
   "video_size_MB":"None",
   "video_thumbnail":"None",
   "video_watches":"None",
   "video_width":"None",
   "likes":5,
   "comments":0,
   "shares":0,
   "post_url":"https://facebook.com/875365599247603/posts/3855323311251802",
   "link":"None",
   "user_id":"875365599247603",
   "username":"Voix de biskra صوت بسكرة",
   "user_url":"https://facebook.com/Voix.de.biskra/?__tn__=C-R",
   "is_live":false,
   "factcheck":"None",
   "shared_post_id":"None",
   "shared_time":"None",
   "shared_user_id":"None",
   "shared_username":"None",
   "shared_post_url":"None",
   "available":true,
   "comments_full":"None",
   "reactors":"None",
   "w3_fb_url":"None"
}`
neon-ninja commented 3 years ago
posts = list(get_posts(
    post_urls=["3855820361202097", "3855323311251802"],
    options = {"reactors": True},
    cookies="cookies.txt"
))
pprint.pprint(posts)

returns

[{'available': True,
  'comments': 0,
  'comments_full': None,
  'factcheck': None,
  'fetched_time': datetime.datetime(2021, 5, 11, 16, 5, 50, 360927),
  'image': 'https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=58vEoAlBjygAX_qU7ty&_nc_ht=scontent.fakl1-2.fna&tp=14&oh=12e12a3c924813f2bab6b4d126d3288a&oe=60C143A0',
  'image_lowquality': 'https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p240x240/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=58vEoAlBjygAX_qU7ty&_nc_ht=scontent.fakl1-2.fna&tp=3&oh=0f0b9138b0f415dafebad4b13e98db07&oe=60BFDF35',
  'images': ['https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=58vEoAlBjygAX_qU7ty&_nc_ht=scontent.fakl1-2.fna&tp=14&oh=12e12a3c924813f2bab6b4d126d3288a&oe=60C143A0'],
  'images_description': ['May be an image of \u200eone or more people and '
                         '\u200etext that says "\u200eمساء الخير اخي ارجو ان '
                         'تنشرو دون ذكر اسمي وجدت صورة ووصل استلام ملف تسجيل '
                         'امتحان باكالوريا باسم طهراوي رميساء واريد ان اوصل '
                         'لها امانتها باذن الله نشكرك على مراسلتنا نحن '
                         'نسعى\u200e"\u200e\u200e'],
  'images_lowquality': ['https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p240x240/184285532_3855820291202104_114856109806233400_n.jpg?_nc_cat=104&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=58vEoAlBjygAX_qU7ty&_nc_ht=scontent.fakl1-2.fna&tp=3&oh=0f0b9138b0f415dafebad4b13e98db07&oe=60BFDF35'],
  'images_lowquality_description': ['May be an image of \u200eone or more '
                                    'people and \u200etext that says '
                                    '"\u200eمساء الخير اخي ارجو ان تنشرو دون '
                                    'ذكر اسمي وجدت صورة ووصل استلام ملف تسجيل '
                                    'امتحان باكالوريا باسم طهراوي رميساء واريد '
                                    'ان اوصل لها امانتها باذن الله نشكرك على '
                                    'مراسلتنا نحن نسعى\u200e"\u200e\u200e'],
  'is_live': False,
  'likes': 8,
  'link': None,
  'post_id': '3855820361202097',
  'post_text': 'من #رسائلكم\n#khaled\n\nFrom your #messages\n#khaled',
  'post_url': 'https://facebook.com/story.php?story_fbid=3855820361202097&id=875365599247603',
  'reactions': {'like': 8},
  'reactors': [{'link': 'https://facebook.com/Voix.de.biskra/?fref=pb',
                'name': 'Voix de biskra صوت بسكرة',
                'type': None},
               {'link': 'https://facebook.com/profile.php?id=100057774697305&fref=pb',
                'name': "Papillon D'or",
                'type': 'Like'},
               {'link': 'https://facebook.com/OmGm07?fref=pb',
                'name': 'Om Gm',
                'type': 'Like'},
               {'link': 'https://facebook.com/sahra.ziban?fref=pb',
                'name': 'يونس لبصايرة',
                'type': 'Like'},
               {'link': 'https://facebook.com/profile.php?id=100035967972120&fref=pb',
                'name': 'سجودي لرب العالمين',
                'type': 'Like'},
               {'link': 'https://facebook.com/profile.php?id=100020005092329&fref=pb',
                'name': 'Adouane Charefeddine',
                'type': 'Like'},
               {'link': 'https://facebook.com/khald.khwald.9?fref=pb',
                'name': 'Wahid Jabde Roho',
                'type': 'Like'},
               {'link': 'https://facebook.com/profile.php?id=100005712421960&fref=pb',
                'name': 'Kamal Madridi',
                'type': 'Like'}],
  'shared_post_id': None,
  'shared_post_url': None,
  'shared_text': '',
  'shared_time': None,
  'shared_user_id': None,
  'shared_username': None,
  'shares': 0,
  'text': 'من #رسائلكم\n#khaled\n\nFrom your #messages\n#khaled',
  'time': datetime.datetime(2021, 5, 11, 13, 5, 48, 699983),
  'user_id': '875365599247603',
  'user_url': 'https://facebook.com/Voix.de.biskra/?refid=52&__tn__=C-R',
  'username': 'Voix de biskra صوت بسكرة',
  'video': None,
  'video_duration_seconds': None,
  'video_height': None,
  'video_id': None,
  'video_quality': None,
  'video_size_MB': None,
  'video_thumbnail': None,
  'video_watches': None,
  'video_width': None,
  'w3_fb_url': 'https://www.facebook.com/story.php?story_fbid=3855820361202097&id=875365599247603'},
 {'available': True,
  'comments': 0,
  'comments_full': None,
  'factcheck': None,
  'fetched_time': datetime.datetime(2021, 5, 11, 16, 5, 53, 648502),
  'image': 'https://scontent.fakl1-3.fna.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=tUKoBsTDY-8AX8v7YoK&_nc_ht=scontent.fakl1-3.fna&tp=14&oh=8bc9999168cebd3a19ae5e2b834b55e4&oe=60BDE953',
  'image_lowquality': 'https://scontent.fakl1-3.fna.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p320x320/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=tUKoBsTDY-8AX8v7YoK&_nc_ht=scontent.fakl1-3.fna&tp=3&oh=9d9060ebcebef2a3ea9e7949f871c6b6&oe=60C0BF17',
  'images': ['https://scontent.fakl1-3.fna.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=tUKoBsTDY-8AX8v7YoK&_nc_ht=scontent.fakl1-3.fna&tp=14&oh=8bc9999168cebd3a19ae5e2b834b55e4&oe=60BDE953'],
  'images_description': ['May be an image of text'],
  'images_lowquality': ['https://scontent.fakl1-3.fna.fbcdn.net/v/t1.6435-0/cp0/e15/q65/p320x320/185020517_3855323201251813_2377859802777565733_n.jpg?_nc_cat=103&ccb=1-3&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_ohc=tUKoBsTDY-8AX8v7YoK&_nc_ht=scontent.fakl1-3.fna&tp=3&oh=9d9060ebcebef2a3ea9e7949f871c6b6&oe=60C0BF17'],
  'images_lowquality_description': ['May be an image of text'],
  'is_live': False,
  'likes': 5,
  'link': None,
  'post_id': '3855323311251802',
  'post_text': 'من الصفحة الرسمية لفريق اتحاد بسكرة لكرة القدم\n'
               '#فلسطين\n'
               '\n'
               'From the official page of the Biskra Football Federation team\n'
               '#فلسطين',
  'post_url': 'https://facebook.com/story.php?story_fbid=3855323311251802&id=875365599247603',
  'reactions': {'like': 5, 'love': 2},
  'reactors': [{'link': 'https://facebook.com/profile.php?id=100061337850334&fref=pb',
                'name': 'Fa Res',
                'type': 'Love'},
               {'link': 'https://facebook.com/profile.php?id=100060111519908&fref=pb',
                'name': 'Afaf Chergui',
                'type': 'Like'},
               {'link': 'https://facebook.com/OmGm07?fref=pb',
                'name': 'Om Gm',
                'type': 'Like'},
               {'link': 'https://facebook.com/sahra.ziban?fref=pb',
                'name': 'يونس لبصايرة',
                'type': 'Love'},
               {'link': 'https://facebook.com/saja.jana.77?fref=pb',
                'name': 'محمد سليم زارد',
                'type': 'Like'},
               {'link': 'https://facebook.com/profile.php?id=100012357407162&fref=pb',
                'name': 'زهرة التولين',
                'type': 'Like'},
               {'link': 'https://facebook.com/profile.php?id=100007589718055&fref=pb',
                'name': 'Yassmin Yassmin',
                'type': 'Like'}],
  'shared_post_id': None,
  'shared_post_url': None,
  'shared_text': '',
  'shared_time': None,
  'shared_user_id': None,
  'shared_username': None,
  'shares': 1,
  'text': 'من الصفحة الرسمية لفريق اتحاد بسكرة لكرة القدم\n'
          '#فلسطين\n'
          '\n'
          'From the official page of the Biskra Football Federation team\n'
          '#فلسطين',
  'time': datetime.datetime(2021, 5, 11, 8, 5, 51, 114211),
  'user_id': '875365599247603',
  'user_url': 'https://facebook.com/Voix.de.biskra/?refid=52&__tn__=C-R',
  'username': 'Voix de biskra صوت بسكرة',
  'video': None,
  'video_duration_seconds': None,
  'video_height': None,
  'video_id': None,
  'video_quality': None,
  'video_size_MB': None,
  'video_thumbnail': None,
  'video_watches': None,
  'video_width': None,
  'w3_fb_url': 'https://www.facebook.com/story.php?story_fbid=3855323311251802&id=875365599247603'}]

Do you have any warning about locale output when you run get_posts? For example:

/home/nyou045/git/facebook-scraper/facebook_scraper/facebook_scraper.py:196: UserWarning: Locale detected as en_GB - for best results, set to en_US
  warnings.warn(f"Locale detected as {locale} - for best results, set to en_US")

Note that based on my locale, I receive an automatic translation into English, which you don't seem to

Also it would seem that cookies are required to see reactors for these 2 posts, try open https://m.facebook.com/Voix.de.biskra/posts/3855820361202097 in an incognito window

fashan7 commented 3 years ago

earlier it worked without cookies. reactors are visible in facebook-scraper

neon-ninja commented 3 years ago

Reactions/reactors might be visible without cookies for larger pages like Nintendo, but not smaller pages like this one. Even then, it's very easy to trigger an IP ban to stop you reading too many reaction counts anonymously. Best to pass cookies for this task.

posts = get_posts(
    "Nintendo",
    options = {"reactors": True}
)
for post in posts:
    print(post.get("post_id"), post.get("reactions"), post.get("reactors"))
4112996902118065 {'like': 714, 'love': 198, 'support': 12, 'anger': 1} None
4106669112750844 {'like': 473, 'love': 87, 'wow': 9, 'haha': 7, 'support': 7, 'anger': 7} None
4088623351222087 {'like': 490, 'love': 77, 'support': 4, 'anger': 4, 'wow': 3} None
4085738151510607 None None
4085430424874713 None None
4079635875454168 None None
4064916226926133 None None
4063920557025700 None None
4061286243955798 None None
4054943884590034 None None
4044341405650282 None None
fashan7 commented 3 years ago

@neon-ninja thanks for the information