moda20 / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
60 stars 23 forks source link

getting profile pic #57

Open boboliiii opened 1 month ago

boboliiii commented 1 month ago

hi there, thanks again for your amazing program!

i was wondering if there's a way to get the (url of) the profile pic? when i try and use get_profile i get nothing but the user's name (example below).

{'Friend_count': None, 'Follower_count': None, 'Following_count': None, 'Name': 'Mark Zuckerberg'}

i was wondering if there's any way to get the profile pic (and the about info)?

thanks in advance

moda20 commented 3 weeks ago

@boboliiii just updated the repo, get_page_info will get you the necessary information including the profile and cover pictures

boboliiii commented 3 weeks ago

thanks so much for doing this! i managed to do it myself in parallel, i'm quite a sloppy programmer though so i will not share my way unless you want me to.

little things that might be helpful to other people:

for me requests.get was crashing about 1 in 100 times, because somehow the url would be changed to intent://profile..blahblah..fallback_url.. .. not sure why it was doing this but changing the https to http magically stopped this behaviour.

to get full sized pics, i added "cookie": "locale=en_US;noscript=1", to the headers.json (and also chose a phone with a good screen like the latest Samsung). it's important to scrape the one named og:image and not the img src (for example, my code is: linktoit = response2.html.html.split("og:image\" content=\"")[1].split("\"")[0].replace("&","&")

unsure if any of this is news to you but maybe it'll help any other fellow travellers that are plodding through the same issues

thanks again for you code, i've learned a lot from it

boboliiii commented 3 weeks ago

the replace above should be replace & amp ; to &, (without spaces) github erased that last bit