GithubHelp home page GithubHelp logo

fb_scrape's Introduction

FB_Scrape

This gem provides a utility for scraping facebook posts and comments. You will require a facebook app id to use this gem

Installation

Add this line to your application's Gemfile:

  gem 'fb_scrape'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install fb_scrape

Usage

Getting information about a Facebook page

  require 'fb_scrape'

  client = FBScrape::Client.new("page_name", "access_token")
  puts client.id
  puts client.name

Loading all the posts for an Facebook account

  require 'fb_scrape'
  client = FBScrape::Client.new("page_name", "access_token", "page_id")
  client.load

  puts client.posts.length

Limiting the number of posts

You can limit the number of posts returned

require 'fb_scrape'
client = FBScrape::Client.new("page_name", "access_token", "page_id", 10)
client.load

puts client.posts.length <= 10

Loading a post

  require 'fb_scrape'

  post = FBScrape::Post.load_from_id(id, access_token)    
  puts post.has_more_comments?

  post.load_all_comments
  puts post.has_more_comments?

Loading a comment and its replies

  require 'fb_scrape'

  comment = FBScrape::Comment.new(payload, access_token, page_id)
  comment.load_replies

  puts comment.comments.count
  puts comment.has_more_replies?
  comment.load_all_replies
  puts comment.comments.count

Loading an entire conversation

  require 'fb_scrape'

  conversation = FBScrape::Conversation.new(conversation_id, page_id, token)
  puts conversation.messages.count

Using the CLI

You can use the CLI to get a dump in JSON of posts and comments

  gem install fb_scrape

  fb_scrape help

  # get the page id for a url
  fb_scrape id --page_name theusername --token token

  # load all the posts for an account
  fb_scrape posts --page_name theusername --token token

  # load all the comments for a post
  fb_scrape comments --id post_id --token token --page_id page_id

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ongair/ig_scrape.

License

The gem is available as open source under the terms of the MIT License.

fb_scrape's People

Contributors

kimenye avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.