RadiantHex
RadiantHex

Reputation: 25597

Facebook Page details and the RESTful API?

Hi I have a list of Facebook Page urls

eg...
http://www.facebook.com/daftpunk
http://www.facebook.com/DavidGuetta
...

What's the best way to:

Help would be very much appreciated.

Upvotes: 2

Views: 513

Answers (4)

Karl B
Karl B

Reputation: 1597

Without scraping any content (which is against Facebook's terms of service anyway):

  1. Extract the username part of the URL i.e. the bit after the www.facebook.com/
  2. Do an FQL query of the form select fan_count from page where username='michaeljackson'
  3. If a result is return, you know it's a Page and not a user's profile.

See the Page FQL table for other data you can retrieve in the same call.

Upvotes: 3

GSto
GSto

Reputation: 42380

The # of fans is in an a tag with the class 'FanManager'. you can use Beautiful Soup to get the contents of this a tag, and regular expressions to get the data from the string (ex: 1,000,000 fans) as an int or whatever you would like.

To see if the page exists, check some of the tags to see if you are on the 404 page.

Upvotes: 1

Corey Goldberg
Corey Goldberg

Reputation: 60664

use urllib2 or pyfacebook to fetch the content

use BeautifulSoup or lxml to parse it

use the re module (regular expressions) to extract content for your verification and data gathering

Upvotes: 2

Seb
Seb

Reputation: 17845

You can use scrapy or BeautifulSoup to scrape the content.

Upvotes: 0

Related Questions