开发者

How to get information from facebook using python?

I've looked at a lot of questions and libs and didn't found exactly what I wanted. Here's the thing, I'm developing an application in python for a user to get all sorts of things from social networks accounts. I'm having trouble with facebook. I would like, if possible, a step-by-step tutorial on the code and libs to use to get a user's information, from posts to photos information (with the user's login information, and how to do it, because I've had a 开发者_StackOverflow中文版lot of problem with authentication).

Thank you


I strongly encourage you to use Facebook's own APIs.

First of all, check out documentation on Facebook's Graph API https://developers.facebook.com/docs/reference/api/. If you are not familiar with JSON, DO read a tutorial on it (for instance http://secretgeek.net/json_3mins.asp).

Once you grasp the concepts, start using this API. For Python, there are at several alternatives:

  • facebook/python-sdk https://github.com/facebook/python-sdk
  • pyFaceGraph https://github.com/iplatform/pyFaceGraph/
  • It is also semitrivial to write a simple HTTP client that uses the graph API

I would suggest you to check out the Python libraries, try out the examples in their documentation and see if they are working and do the stuff you need.

Only as a last resort, would I write a scraper and try to extract data with screenscraping (it is much more painful and breaks more easily).


I have not used this with Facebook, but in the past when I had to scrape a site that required login I used Mechanize to handle the login and scraping and Beautiful Soup to parse the resulting HTML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜