kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.46k stars 634 forks source link

Download Info of Single URL #196

Open trada96 opened 3 years ago

trada96 commented 3 years ago

I have a video's URL, so I wanna extract the raw URL, but I know how to do it, please help me

kevinzg commented 3 years ago

I think youtube-dl is better suited for that.

neon-ninja commented 3 years ago

What info do you mean? Associated text / post id / time etc? Because the code

from facebook_scraper import get_posts
import pprint
post = list(get_posts(post_urls=["Nintendo/posts/1926829187474205"], cookies="cookies.txt"))
pprint.pprint(post)

returns

[{'available': True,
  'comments': 0,
  'comments_full': None,
  'factcheck': None,
  'image': None,
  'images': None,
  'is_live': False,
  'likes': 0,
  'link': None,
  'post_id': '1926829187474205',
  'post_text': "It's Bunny Dango time! 🍡 #MHRise",
  'post_url': 'https://facebook.com/story.php?story_fbid=1926829187474205&id=285708024919671',
  'shared_post_id': None,
  'shared_post_url': None,
  'shared_text': '',
  'shared_time': None,
  'shared_user_id': None,
  'shared_username': None,
  'shares': 0,
  'text': "It's Bunny Dango time! 🍡 #MHRise",
  'time': datetime.datetime(2021, 4, 3, 13, 0),
  'user_id': '285708024919671',
  'username': 'Nintendo',
  'video': 'https:\\/\\/video.fhlz2-1.fna.fbcdn.net\\/v\\/t42.1790-2\\/165983974_2829462653936593_2321884250676936292_n.mp4?_nc_cat=106&ccb=1-3&_nc_sid=985c63&efg=eyJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&_nc_ohc=ahDD7t87CugAX-LTaSd&_nc_ht=video.fhlz2-1.fna&oh=150d3981b425064147cf0872e8196f0d&oe=606D27B5',
  'video_id': '1122161831620686',
  'video_thumbnail': 'https://scontent.fhlz2-1.fna.fbcdn.net/v/t15.5256-10/cp0/e15/q65/s320x320/121903962_1122189668284569_5064187115848171165_n.jpg?_nc_cat=108&ccb=1-3&_nc_sid=ccf8b3&efg=eyJpIjoidCJ9&_nc_ohc=q-pVmZ_EdQAAX93M4Ks&_nc_ht=scontent.fhlz2-1.fna&tp=9&oh=10cdf8cbb40d9ed1e0a5561ddb2f68d5&oe=609259FC'}]

Looks like that video url might need a .replace("\\", "")