question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Do you plan on adding get_profile to get the About section but for pages as well?

See original GitHub issue

I am using this library for a research project and I want to thank you for all your hard work 😃

I have a few URLs that I wish to get their profile info (About Section). The problem is that I don’t know what type of User the URL belongs to (A page or regular user). Thankfully using your get_posts function I can get the user_id, but if it’s a page, I can’t use your get_profile for it.

It works fine for User accounts.

The format I am passing to get_posts is:

"unique name of the page"/posts/"post id"

Other questions:

  1. I am also trying to get the user_id from a post in the following form:

https://www.facebook.com/photo.php?fbid=495386170902530&set=pb.100012934538675.-2207520000..&type=3

But it tells me:

HTTPError: 404 Client Error: Not Found for url: https://m.facebook.com/photo.php?fbid=495386170902530&set=pb.100012934538675.-2207520000..&type=3/

I am just using the code from the examples.

Example of my code:


for post in get_posts("elisamartinezfuentes/posts/1190292224745251", cookies=cookie_path, options={"allow_extra_requests": True}):
    account = post['user_id']

print(get_profile(account, cookies=cookie_path))

TL;DR: I need to get the info on the public about section for Pages/Groups/Users

I apologize if this is not the correct format for an issue.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
neon-ninjacommented, Jun 11, 2021

What information are you trying to extract from a page’s about section that get_page_info doesn’t extract? Do you have a sample page where it doesn’t work? I’ve mostly just tested it with Nintendo’s page.

With directly extracting a post, you should signify to the scraper that the URL represents one post so that it doesn’t try to paginate. The argument for this is post_urls. This code:

post_urls = ["https://www.facebook.com/photo.php?fbid=495386170902530&set=pb.100012934538675.-2207520000..&type=3"]
pprint(next(get_posts(post_urls=post_urls, cookies="cookies.txt")))

Outputs:

{'available': True,
 'comments': 7,
 'comments_full': None,
 'factcheck': None,
 'image': 'https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/38280444_495386177569196_4472689928857190400_n.jpg?_nc_cat=109&ccb=1-3&_nc_sid=05277f&efg=eyJpIjoidCJ9&_nc_ohc=3tIZ-TSPPtAAX9NwgPP&_nc_ht=scontent.fakl1-2.fna&tp=14&oh=a0acf6d6286a8451a2060da1901d7db5&oe=60C895A9&manual_redirect=1',
 'image_lowquality': None,
 'images': ['https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-9/fr/cp0/e15/q65/38280444_495386177569196_4472689928857190400_n.jpg?_nc_cat=109&ccb=1-3&_nc_sid=05277f&efg=eyJpIjoidCJ9&_nc_ohc=3tIZ-TSPPtAAX9NwgPP&_nc_ht=scontent.fakl1-2.fna&tp=14&oh=a0acf6d6286a8451a2060da1901d7db5&oe=60C895A9&manual_redirect=1'],
 'images_description': None,
 'images_lowquality': [],
 'images_lowquality_description': [],
 'is_live': False,
 'likes': 6,
 'link': None,
 'original_request_url': 'https://www.facebook.com/photo.php?fbid=495386170902530&set=pb.100012934538675.-2207520000..&type=3',
 'post_id': '495386170902530',
 'post_text': 'Elisa Martínez Fuentes',
 'post_url': 'https://m.facebook.com/495386170902530',
 'reaction_count': None,
 'reactions': None,
 'reactors': None,
 'shared_post_id': None,
 'shared_post_url': None,
 'shared_text': None,
 'shared_time': None,
 'shared_user_id': None,
 'shared_username': None,
 'shares': 0,
 'text': 'Elisa Martínez Fuentes',
 'time': datetime.datetime(2018, 8, 3, 0, 0),
 'user_id': None,
 'user_url': 'https://facebook.com/elisamartinezfuentes?refid=13&__tn__=%2Cg',
 'username': 'Elisa Martínez Fuentes',
 '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': None}
0reactions
neon-ninjacommented, Jun 15, 2021

This function works by finding a sample post and extracting the JSON-LD, which seems to vary depending on the post. Try this - https://github.com/kevinzg/facebook-scraper/commit/58629bc6f5474a3e59a2a90eff3aca439296e8ca

from facebook_scraper import *
from pprint import pprint
pprint(get_page_info("albertahealthservices", cookies="cookies.txt"))

outputs

{'about': 'http://www.albertahealthservices.ca/\n'
          'We are the provincial health authority responsible for planning and '
          'delivering health services to Albertans. Please read our Privacy '
          'Notice: http://bit.ly/102zhkz before posting on our page.\n'
          'Government Organization\n'
          'See what Alberta Health Services is doing in Messenger\n'
          'Get Started\n'
          'The AHS Facebook page was created to support Albertans as you make '
          'decisions about your own health and the health of your family, and '
          'help connect you to resources and services that are important to '
          'you.\n'
          '\n'
          'Privacy Notice:\n'
          '\n'
          'In accordance with health and privacy legislation, please do not '
          'post your personal health information or that of anyone else on '
          'this site. AHS does not provide personal medical advice on public '
          'social media sites. Anyone seeking medical advice should contact '
          'their physician or call HealthLink Alberta at 1-866-408-5465. In '
          'case of emergency, call 911 immediately.\n'
          '\n'
          'The following content is subject to removal from any AHS social '
          'media site:\n'
          '• Personal or Health Information or other confidential information\n'
          '• Abusive or vulgar language\n'
          '• Irrelevant to the subject matter or not related to AHS\n'
          '• Spam or another form of advertising; and/or violations of federal '
          'or provincial law\n'
          '\n'
          'AHS advises you that this site is public and any information posted '
          'on the site by you indicates your consent to share your '
          'information. Facebook retains ownership of the information '
          'regardless of whether the site is restricted and moderated. '
          'Individuals are encouraged to read Facebook’s privacy policy '
          'regarding the use of personal information posted on the site.\n'
          'Products\n'
          'For a complete list of programs, services, resources, news and '
          'initiatives at AHS, visit www.albertahealthservices.ca\n'
          '\n'
          '\n'
          'MEDICAL CARE\n'
          '\n'
          '\n'
          'Note: If you are concerned that you are seriously ill or injured, '
          'go to the nearest Emergency Department. Patients with potentially '
          'life-threatening conditions should immediately phone 911.\n'
          '\n'
          '\n'
          'Health Care Options\n'
          '\n'
          'Each community in Alberta offers a different range of health care '
          'services and programs. Use the information in this chart to help '
          'you choose and find the best health care and treatment option for '
          'your needs.\n'
          '\n'
          'http://www.albertahealthservices.ca/3381.asp\n'
          '\n'
          '\n'
          'Health Link Alberta\n'
          '\n'
          'Anyone in Alberta with a health question or concern can call to '
          'talk to a Registered Nurse and other health professionals 24 hours '
          'a day, seven days a week:\n'
          '\n'
          'Toll-free: 1-866-408-5465 (LINK)\n'
          'Edmonton: 780-408-5465 (LINK)\n'
          'Calgary: 403-943-5465 (LINK)\n'
          '\n'
          '\n'
          'My Health Alberta\n'
          '\n'
          'MyHealthAlberta is a single source of trusted online health '
          'information and health tools developed in partnership between the '
          'Government of Alberta and Alberta Health Services. The information '
          'and tools you will find on MyHealthAlberta were developed in '
          'consultation with health professionals, and Albertans.\n'
          '\n'
          'Check symptoms and find information on hundreds of health topics '
          'at:\n'
          '\n'
          'https://myhealth.alberta.ca/Pages/default.aspx\n'
          '\n'
          '\n'
          'Find Hospitals and Facilities\n'
          '\n'
          'Search for a hospital or health care facility near you:\n'
          '\n'
          'http://www.albertahealthservices.ca/facilities.asp?pid=facilities\n'
          '\n'
          '\n'
          'AHS Emergency Department Wait Times\n'
          '\n'
          'Before heading to the emergency department, check to see the '
          'estimated wait times at an emergency room near you. Please note: '
          'The estimated waiting time to see a physician in Emergency is '
          'approximate and is for informational purposes only. We provide care '
          'to the most critical cases first.\n'
          '\n'
          'http://www.albertahealthservices.ca/4770.asp\n'
          'Understanding Wait Times FAQ: '
          'http://www.albertahealthservices.ca/Data/ahs-data-edm-understanding-wait-times-patients.pdf\n'
          '\n'
          '\n'
          'FEEDBACK\n'
          '\n'
          '\n'
          'Patient Concerns and Feedback\n'
          '\n'
          'Your experience of care holds important information that helps us '
          'to continuously improve. We want to hear what you have to say so we '
          "can better understand what we're doing right and what we can do "
          'better.\n'
          '\n'
          'www.albertahealthservices.ca/patientfeedback.asp\n'
          '\n'
          '\n'
          'IN YOUR COMMUNITY\n'
          '\n'
          '\n'
          'Find Programs and Services\n'
          '\n'
          'Alberta Health Services has a wide range of programs and services '
          'available at locations across the province to serve the needs of '
          'community residents.\n'
          '\n'
          'http://www.albertahealthservices.ca/services.asp?pid=services\n'
          '\n'
          '\n'
          'Advisory Councils\n'
          '\n'
          'The Alberta Health Services team is committed to engaging the '
          'public in a respectful, open and accountable manner to support the '
          'strategic direction of the organization. Community input and '
          'feedback allows us to better address the health needs of '
          'communities. Learn more about our health and provincial advisory '
          'councils and how you can get involved:\n'
          '\n'
          'http://www.albertahealthservices.ca/communityrelations.asp\n'
          '\n'
          'Foundations and Trusts\n'
          '\n'
          'Alberta Health Services relies on its 64 Foundation & Health Trust '
          'partners to help drive innovation in health care. These '
          'organizations work diligently to gather community support, develop '
          'partnerships and raise critically-needed funds to further enhance '
          'the care delivered to patients and families in Alberta. They are '
          'committed to building excellence within our system.\n'
          '\n'
          'http://www.albertahealthservices.ca/255.asp\n'
          '\n'
          '\n'
          'CONNECT\n'
          '\n'
          'Social Media\n'
          '\n'
          'AHS uses a variety of social media channels to connect with '
          'Albertans in their communities and beyond, including Twitter, '
          'YouTube and Facebook. To find out more, visit:\n'
          '\n'
          'http://www.albertahealthservices.ca/socialmedia.asp\n'
          '\n'
          '\n'
          'Mobile App\n'
          '\n'
          'AHS is working to ensure that Albertans have innovative ways to '
          'access information about healthcare services by providing '
          'applications for mobile devices. Learn more and download the AHS '
          'Mobile App:\n'
          '\n'
          'http://www.albertahealthservices.ca/mobile.asp\n'
          '\n'
          '\n'
          'WORKING AT AHS\n'
          '\n'
          '\n'
          'AHS Careers\n'
          '\n'
          'For information about career opportunities at Alberta Health '
          'Services and steps to apply, please visit the AHS Careers website '
          'at:\n'
          '\n'
          'http://www.albertahealthservices.ca/careers/default.asp\n'
          'Privacy Policy',
 'followers': 83674,
 'image': 'https://scontent.fhlz2-1.fna.fbcdn.net/v/t1.6435-1/fr/cp0/e15/q65/119725810_3424921950879260_840471821714627235_n.jpg?_nc_cat=101&ccb=1-3&_nc_sid=c1fdac&efg=eyJpIjoidCJ9&_nc_ohc=gyZlAtpeMdUAX-40zMi&_nc_ht=scontent.fhlz2-1.fna&tp=14&oh=e41f04782a16416e03fcf70e4f87e808&oe=60CC7132',
 'likes': 74660,
 'name': 'Alberta Health Services',
 'type': 'Organization',
 'url': '/albertahealthservices/'}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Profile Builder – User Profile & User Registration Forms
Powerful user profile plugin for creating front-end login, user registration and edit profile forms. Includes content restriction and user role editor …
Read more >
CHAPTER 4 : DEVELOPING A COMMUNITY PROFILE
Begin with a review of population, housing, and economic characteristics and trends of the broader community and the study area. Such data are...
Read more >
Resources for the Bungie.net API - GitHub
Documentation as one single, gigantic page: https://bungie-net.github.io. This section will be added to as time goes by - we're working with it as...
Read more >
12 Tips to Help You Get Seen More on Facebook - Post Planner
Working hard on your Facebook marketing, but still not showing up in the news feed? We can help. Here's 12 tips to help...
Read more >
Profile Plugin WordPress - Profile Builder Pro - Cozmoslabs
Now all you need to do is add the following shortcode: [wppb-edit-profile] . Publish your page and you are done! Profile Builder is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found