Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sathish316/jsonify_rack_example
Example Rack application using scrapify/jsonify gem to scrap static sites and expose them as JSON APIs
https://github.com/sathish316/jsonify_rack_example
Last synced: 3 months ago
JSON representation
Example Rack application using scrapify/jsonify gem to scrap static sites and expose them as JSON APIs
- Host: GitHub
- URL: https://github.com/sathish316/jsonify_rack_example
- Owner: sathish316
- Created: 2012-05-26T16:02:58.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-05-26T18:25:27.000Z (over 12 years ago)
- Last Synced: 2024-05-31T20:01:25.229Z (6 months ago)
- Language: Ruby
- Size: 90.8 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ScrApify
ScrApify is a gem which scraps static html pages and exposes them as JSON APIs
This is a sample Rack application using scrapify to create a RESTful read only service from static page.
## JSON API (Rack application example)
Scrapify comes with a Rack application called Jsonify which can expose scraped models as JSON.
1 Install scrapify
```
$ gem install scrapify
```2 Define model and attributes
See models/pizza.rb for example
```
class Pizza
include Scrapify::Base
attributes :name, css: '.menu li'
end
```3 In Rack application map the routes you want to expose as JSON using Rack::Builder#map
```
map '/pizzas' do
run Jsonify.new('/pizzas', ::Pizza)
end
```Jsonify will fetch data from static html sites and expose them as JSON in these urls:
* /pizzas
* /pizzas/:idJsonify currently has a limitation where the URLs /pizzas.json and /pizzas/1.json cannot be matched by the same map entry in Rack routes