• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    Ruby
  • Created over 12 years ago
  • Updated about 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ScrApify is a library to build APIs by scraping static sites and use data as models or JSON APIs. It powers APIfy which is used to create JSON APIs from any html or wikipedia page

ScrApify

ScrApify is a library to build APIs by scraping static sites and use data as models or JSON APIs

Installation

$ gem install scrapify

If you're using Bundler, add this to your Gemfile:

gem 'scrapify'

Usage

Define html url and declare attributes using xpath or css selectors. Scrapify classes must have a key attribute defined.

class Pizza
  include Scrapify::Base
  html "http://www.dominos.co.in/menuDetails_ajx.php?catgId=1"

  attribute :name, css: ".menu_lft li a"
  attribute :image_url, xpath: "//li//input//@value"

  key :name
end

Now you can use finder methods to extract data from a static site

> Pizza.all

> pizza = Pizza.find('mushroom')
> pizza.name
> pizza.image_url

> Pizza.first
> Pizza.last

> Pizza.count

JSON API (Rack application example)

Scrapify comes with a Rack application called Jsonify which can expose scraped models as JSON.

Check out this Rack application example for more details:

https://github.com/sathish316/jsonify_rack_example

In your Rack application map the routes you want to expose as JSON using Rack::Builder#map

  map '/pizzas' do
    run Jsonify.new('/pizzas', ::Pizza)
  end

This will respond to two urls index and show with JSON:

  • /pizzas
  • /pizzas/:id

Jsonify currently has a limitation where the URLs /pizzas.json and /pizzas/1.json cannot be matched by the same map entry in Rack routes

JSON API (Rails example)

Scrapify comes with a Rack application called Jsonify which can be used in rails routes to expose scraped models as JSON.

Check out this Rails example for more details:

https://github.com/sathish316/jsonify_rails_example

1 Add scrapify to Gemfile

gem 'scrapify'

2 Define model to scrap data in app/models

class Pizza
  include Scrapify::Base
end

3 Add index and show API to routes

  pizza_api = Jsonify.new('/pizzas', Pizza)
  get 'pizzas' => pizza_api
  get 'pizzas/:id' => pizza_api

Jsonify scraps url and exposes index and show urls as JSON APIs

License

ScrApify is released under the MIT license:

http://www.opensource.org/licenses/MIT

More Repositories

1

pIpe

pIpe is ifttt for websites/webservices linked to webservices/smartphones/desktops with advanced filters
Ruby
224
star
2

metaprogramming_koans

Ruby Metaprograaming Koans (Inspired by EdgeCase RubyKoans).
Ruby
65
star
3

javascript_functional_koans

Functional programming concepts explained in Javascript using "Functional programming for the rest of us" http://www.defmacro.org/ramblings/fp.html
JavaScript
39
star
4

APIfy

Convert data in any static site to JSON API by scraping it dynamically. Try http://apify.heroku.com
JavaScript
10
star
5

jsonify_rack_example

Example Rack application using scrapify/jsonify gem to scrap static sites and expose them as JSON APIs
Ruby
4
star
6

litexte

litexte is a textile parser
Ruby
3
star
7

RunTweeter

RunTweeter is a twitter feed parser which counts total distance and other useful run stats from your tweets
Ruby
2
star
8

object_dojo

ObjectDojo is a utility to practice Object oriented programming using the rules from the article "Object Calisthenics" by JeffBay
Ruby
2
star
9

sicp-scheme

Code and Exercises from SICP in Scheme
Scheme
2
star
10

totalr

Totalr is a Ruby library which provides a simple dsl to do aggregation in models, like totals, percentage, grouping, mean, variance etc
Ruby
2
star
11

jsonify_rails_example

Example Rail application using scrapify/jsonify gem to scrap static sites and use them as models or expose them as JSON APIs
Ruby
2
star
12

gitwall

gitwall is a card wall/todo list for github projects
JavaScript
2
star
13

grammar_nazi

GrammarNazi is a machine learning library that uses N-gram analysis to correct common grammatical errors like it's vs its etc
Ruby
1
star
14

anyscp

anyScp is a simplified file transfer app that transfers files between any two remote machines using scp and a simple REST API
Ruby
1
star
15

UoM

Mixins for Unit of Measurements conversion in Ruby
Ruby
1
star
16

supportcause

Ruby
1
star
17

Builder

Rudimentary XML builder library
Ruby
1
star
18

PaulTheOctopus

Paul the Octopus is a Twitter bot that predicts from the given options
Ruby
1
star
19

jsafederef

Null Safe Dereferencing in Java like Groovy ?.
1
star
20

clojure_koans_online

Clojure koans online in Noir.
JavaScript
1
star
21

99

Solving the famous 99 Problems in Prolog in multiple languages with a common testing ground
Ruby
1
star
22

prognos-spark-example

Spark usage example for Prognos library: https://github.com/sathish316/prognos
Scala
1
star
23

billable

Ruby
1
star
24

dropwizard-multitenancy-example

Java
1
star
25

vaxnotifier

Shell
1
star
26

aitictactoe

Tic Tac Toe Game AI
Ruby
1
star
27

rubymetakoans

Ruby metaprogramming koans online
Ruby
1
star
28

is_unit

IsUnit ensures your unit tests don't have external dependencies or dependencies on other classes unless explicitly stated making your code clean and easy to refactor
Ruby
1
star
29

bingocontest

Bingo game for executing Bingo player bots in programming contests
Ruby
1
star