quick_scrapper 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ nbproject
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in quick_scrapper.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ module QuickScrapper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'scrapi'
2
+
3
+ module QuickScrapper
4
+ # Scraps the selection associated to css_selector +selector+ from the page located at +url+
5
+ #
6
+ # Example: QuickScrapper.scrap("http://bvsatyaram.com", div.priceAvail>div>div.PriceCompare>div.BodyS")
7
+ def self.scrap(url, selector)
8
+ scraper = Scraper.define do
9
+ process selector, :selection => :text
10
+ result :selection
11
+ end
12
+
13
+ uri = URI.parse(url)
14
+ return scraper.scrape(uri)
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "quick_scrapper/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "quick_scrapper"
7
+ s.version = QuickScrapper::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Satyaram B V"]
10
+ s.email = ["bvsatyaram AT gmail DOT com"]
11
+ s.homepage = "http://bvsatyaram.com"
12
+ s.summary = %q{Quickly scraps a selection in a page}
13
+ s.description = %q{Quickly scraps a selection in a page}
14
+
15
+ s.add_dependency "scrapi"
16
+
17
+ s.rubyforge_project = "quick_scrapper"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,22 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
5
+
6
+ require 'test/unit'
7
+ require 'quick_scrapper'
8
+
9
+ class QuickScrapperTest < Test::Unit::TestCase
10
+ def test_tag_selector
11
+ assert_equal "Google", scrap("http://www.google.co.in/", "title")
12
+ end
13
+
14
+ def test_css_selector
15
+ assert_equal "Web", scrap("http://www.google.co.in/", "html body div#mngb div#gog div#gbar nobr a#gb_1.gb1")
16
+ end
17
+
18
+ private
19
+ def scrap(url, selector)
20
+ QuickScrapper.scrap(url, selector)
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quick_scrapper
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Satyaram B V
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-27 00:00:00 +05:30
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: scrapi
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: Quickly scraps a selection in a page
33
+ email:
34
+ - bvsatyaram AT gmail DOT com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - .gitignore
43
+ - Gemfile
44
+ - Rakefile
45
+ - lib/quick_scrapper.rb
46
+ - lib/quick_scrapper/version.rb
47
+ - quick_scrapper.gemspec
48
+ - test/quick_scrapper_test.rb
49
+ has_rdoc: true
50
+ homepage: http://bvsatyaram.com
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project: quick_scrapper
75
+ rubygems_version: 1.3.6
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Quickly scraps a selection in a page
79
+ test_files: []
80
+