facebook-scraper
facebook-scraper copied to clipboard
Single url does not return comments, reactions and reactors
When I get posts by specifying a user account, I get the comments, reactions and reactors perfectly.
But, when I use a single url, no comments, reactions and reactors are returned.
( This is the code for user account (returns comments, reactions and reactors):
#coding:utf8
import sys
import os
if os.path.exists("G:/facebook-scraper-python/filename.txt"):
os.remove("G:/facebook-scraper-python/filename.txt")
from json import dumps
import json
from facebook_scraper import get_posts,_scraper
xposturl=["https://www.facebook.com/talat.oncu/posts/10225784508541143"] #amerikan mandası
with open('G:/facebook-scraper-python/mbasicHeaders.json', 'r') as file:
_scraper.mbasic_headers = json.load(file)
for post in get_posts( \
"talatoncu",
start_url="https://mbasic.facebook.com/talat.oncu", \
base_url="https://mbasic.facebook.com", \
cookies='from_browser', \
extra_requests=True,
#post_urls=xposturl, \
options={"comments": True,"reactors": True,"reactions":True,\
"allow_extra_requests": True, \
"progress": True,"extra_info":True}):
xstring = str(post)
xstring=dumps(post,skipkeys=True,indent=5, default=str,ensure_ascii=False)
f = open('G:/facebook-scraper-python/filename.txt', 'w', encoding='utf-8')
f.write(xstring)
f.close()
This is the code for single url (does not return comments, reactions and reactors):
#coding:utf8
import sys
import os
if os.path.exists("G:/facebook-scraper-python/filename.txt"):
os.remove("G:/facebook-scraper-python/filename.txt")
from json import dumps
import json
from facebook_scraper import get_posts,_scraper
xposturl=["https://www.facebook.com/talat.oncu/posts/10225784508541143"] #amerikan mandası
with open('G:/facebook-scraper-python/mbasicHeaders.json', 'r') as file:
_scraper.mbasic_headers = json.load(file)
for post in get_posts( \
#"talatoncu",
start_url="https://mbasic.facebook.com/talat.oncu", \
base_url="https://mbasic.facebook.com", \
cookies='from_browser', \
extra_requests=True,
post_urls=xposturl, \
options={"comments": True,"reactors": True,"reactions":True,\
"allow_extra_requests": True, \
"progress": True,"extra_info":True}):
#print(post['text'])
xstring = str(post)
xstring=dumps(post,skipkeys=True,indent=5, default=str,ensure_ascii=False)
f = open('G:/facebook-scraper-python/filename.txt', 'w', encoding='utf-8')
f.write(xstring)
f.close()
I tried with
start_url="https://mbasic.facebook.com/talat.oncu/posts/10225784508541143"
and again nothing returned.
The returned json for a single url is as follows:
{
"original_request_url": "https://www.facebook.com/talat.oncu/posts/10225784508541143",
"post_url": "https://mbasic.facebook.com/talat.oncu/posts/10225784508541143",
"post_id": null,
"text": "Türkiye'de Amerikan Mandası Meselesi (1919-1920) ; Dr. Mine Erol; 1972, XII+163 S.; İleri Basımevi, Giresun; [45238]",
"post_text": "Türkiye'de Amerikan Mandası Meselesi (1919-1920) ; Dr. Mine Erol; 1972, XII+163 S.; İleri Basımevi, Giresun; [45238]",
"shared_text": "",
"original_text": null,
"time": "2024-05-28 10:14:00",
"timestamp": null,
"image": "https://scontent.fesb4-4.fna.fbcdn.net/v/t39.30808-6/443839769_10225784508341138_202164743398653783_n.jpg?stp=cp0_dst-jpg_e15_fr_q65&_nc_cat=108&ccb=1-7&_nc_sid=e5c1b6&efg=eyJpIjoiYiJ9&_nc_ohc=A_u9ype1O1wQ7kNvgFM-95I&_nc_ht=scontent.fesb4-4.fna&_nc_gid=AIVktrLisnDTrU8dXy81Fer&oh=00_AYATeCV6Z-KO-a7TQaE91bE8_wlx2yZjfCXeg8DWSp1EWQ&oe=66E8A121",
"image_lowquality": "https://scontent.fesb4-4.fna.fbcdn.net/v/t39.30808-6/443839769_10225784508341138_202164743398653783_n.jpg?stp=cp0_dst-jpg_e15_p600x600_q65&_nc_cat=108&ccb=1-7&_nc_sid=e5c1b6&efg=eyJpIjoiYiJ9&_nc_ohc=A_u9ype1O1wQ7kNvgFM-95I&_nc_ht=scontent.fesb4-4.fna&_nc_gid=A451oQeetT4cH2Vx4PfbMGx&oh=00_AYCGzyUhK3cuuzQk84ydjrvWZN1-j6pdtB_sIaSIiGsBUg&oe=66E8A121",
"images": [
"https://scontent.fesb4-4.fna.fbcdn.net/v/t39.30808-6/443839769_10225784508341138_202164743398653783_n.jpg?stp=cp0_dst-jpg_e15_fr_q65&_nc_cat=108&ccb=1-7&_nc_sid=e5c1b6&efg=eyJpIjoiYiJ9&_nc_ohc=A_u9ype1O1wQ7kNvgFM-95I&_nc_ht=scontent.fesb4-4.fna&_nc_gid=AIVktrLisnDTrU8dXy81Fer&oh=00_AYATeCV6Z-KO-a7TQaE91bE8_wlx2yZjfCXeg8DWSp1EWQ&oe=66E8A121",
"https://scontent.fesb3-2.fna.fbcdn.net/v/t39.30808-6/441902118_10225751509436186_4634580799677439445_n.jpg?stp=cp0_dst-jpg_e15_fr_q65&_nc_cat=102&ccb=1-7&_nc_sid=e5c1b6&efg=eyJpIjoiYiJ9&_nc_ohc=PG2cWGE6sEQQ7kNvgGjg7Ov&tn=Eu6n6RS_teB-1Fo6&_nc_ht=scontent.fesb3-2.fna&_nc_gid=AixuH7DLs48VUuZfNVhATgE&oh=00_AYDQfla2Q36c_vh3Hg18U9qxCwNkrcrgRlKwGp2Xabl3uw&oe=66E8755B"
],
"images_description": [],
"images_lowquality": [
"https://scontent.fesb4-4.fna.fbcdn.net/v/t39.30808-6/443839769_10225784508341138_202164743398653783_n.jpg?stp=cp0_dst-jpg_e15_p600x600_q65&_nc_cat=108&ccb=1-7&_nc_sid=e5c1b6&efg=eyJpIjoiYiJ9&_nc_ohc=A_u9ype1O1wQ7kNvgFM-95I&_nc_ht=scontent.fesb4-4.fna&_nc_gid=A451oQeetT4cH2Vx4PfbMGx&oh=00_AYCGzyUhK3cuuzQk84ydjrvWZN1-j6pdtB_sIaSIiGsBUg&oe=66E8A121"
],
"images_lowquality_description": [
null
],
"video": null,
"video_duration_seconds": null,
"video_height": null,
"video_id": null,
"video_quality": null,
"video_size_MB": null,
"video_thumbnail": null,
"video_watches": null,
"video_width": null,
"likes": 0,
"comments": 0,
"shares": 0,
"link": null,
"links": [],
"user_id": null,
"username": "Talat Öncü",
"user_url": "https://facebook.com/talat.oncu?eav=AfbA2IwkKHkzER_mdszBmZsRIhwcnY1uVNwBM8PPbbA_SARBOHMGT_GSdAdTAbN-khs&__tn__=C-R&paipv=0",
"is_live": false,
"factcheck": null,
"shared_post_id": null,
"shared_time": null,
"shared_user_id": null,
"shared_username": null,
"shared_user_url": null,
"shared_post_url": null,
"available": true,
"comments_full": [],
"reactors": null,
"w3_fb_url": null,
"reactions": null,
"reaction_count": 0,
"with": null,
"page_id": null,
"sharers": null,
"translated_text": "",
"image_id": null,
"image_ids": []
}