kan_dian_ying 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4536306675da7b0e6113b92b7d4d0a34f7039958
4
+ data.tar.gz: 71fce45a7736f82001504942bfdbc8540c72a9cb
5
+ SHA512:
6
+ metadata.gz: 563fc490eb7d2ce5f898e88ab0f94b74cbbb8281100b2d11dff08c8df3d3dcd1d3d49da05db19b4f753af6ef9f767ef8da6a9363ab3d459e8fc0901333a1ed1a
7
+ data.tar.gz: 1e39f8a36e84184ccd4e549186f2a8db25195c247550befad0a08f9827dfb697efe1909ece45d046824aab7f27ace847eebbd65a5b26bc145d2a33016b6d23c4
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://www.rubygems.org'
2
+
3
+ ruby '2.2.1'
4
+
5
+ gemspec
data/LICENSE ADDED
File without changes
@@ -0,0 +1 @@
1
+ # Hsinchu_Movie
File without changes
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/kandianying'
3
+
4
+ movie = HsinChuMovie.new(ARGV[1].to_s)
5
+ movie.movie_table_output
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+ require 'kandianying/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'kan_dian_ying'
6
+ s.version = KanDianYing::VERSION
7
+ s.date = KanDianYing::DATE
8
+ s.executables << 'kandianying'
9
+ s.summary = 'Get movie information in Hsin Chu'
10
+ s.description = 'Get movie information in Hsin Chu'
11
+ s.authors = %w(stonegold546 huangjr pengyuchen stozuka)
12
+ s.email = %w(stonegold546@gmail.com jr@nlplab.cc
13
+ pengyu@gmail.com stozuka@gmail.com)
14
+ s.files = `git ls-files`.split("\n")
15
+ # s.test_files = `git ls-files spec/*`.split("\n")
16
+ s.homepage = 'https://github.com/SOAupstart2/Hsinchu_Movie'
17
+ s.license = 'MIT'
18
+
19
+ # s.add_development_dependency 'minitest'
20
+ # s.add_development_dependency 'minitest-rg'
21
+ # s.add_development_dependency 'vcr'
22
+ # s.add_development_dependency 'webmock'
23
+ s.add_runtime_dependency 'nokogiri'
24
+ end
Binary file
@@ -0,0 +1,10 @@
1
+ require_relative './kandianying/vieshow'
2
+
3
+ # class for crawling movie information
4
+ class HsinChuMovie
5
+ include VieShow
6
+
7
+ def movie_table_output
8
+ puts to_json
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # Gem info
2
+ module KanDianYing
3
+ VERSION = '0.0.1'
4
+ DATE = '2015-10-24'
5
+ end
@@ -0,0 +1,56 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'json'
4
+
5
+ # Scraper for VieShow
6
+ module VieShow
7
+ # initialize movie_table with url
8
+ def initialize(visCinemaID)
9
+ url = 'http://sales.vscinemas.com.tw/ticketing/visPrintShowTimes.aspx?'\
10
+ 'visCinemaID=' + visCinemaID
11
+ open_doc = open(url, 'Cookie' => 'AspxAutoDetectCookieSupport=1')
12
+ doc = Nokogiri::HTML(open_doc)
13
+ @table = doc.xpath("//*[@class='PrintShowTimesTable']//td"\
14
+ "[@class='PrintShowTimesFilm' "\
15
+ "or @class='PrintShowTimesDay' "\
16
+ "or @class='PrintShowTimesSession']")
17
+ @movie_table = Hash.new { |hash, key| hash[key] = [] }
18
+ make_movie_table
19
+ end
20
+
21
+ # make movie_table like the structure {"name"=>[[day,time],"name2".....}
22
+ def make_movie_table
23
+ current_movie = ''
24
+ @table.each do |td|
25
+ current_movie = movie_conditions(td, current_movie)
26
+ end
27
+ end
28
+
29
+ # make make_movie_table simple
30
+ def movie_conditions(td, current_movie)
31
+ case td.first[1]
32
+ when 'PrintShowTimesFilm'
33
+ current_movie = td.text
34
+ when 'PrintShowTimesDay'
35
+ @movie_table[current_movie] << [td.text]
36
+ when 'PrintShowTimesSession'
37
+ @movie_table[current_movie][-1] << td.text
38
+ end
39
+ current_movie
40
+ end
41
+
42
+ # get all movies' names
43
+ def movie_name
44
+ @movie_table.keys
45
+ end
46
+
47
+ # fetch movie_table
48
+ def movie_table
49
+ @movie_table
50
+ end
51
+
52
+ # get json format from movie_table
53
+ def to_json
54
+ @movie_table.to_json
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kan_dian_ying
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - stonegold546
8
+ - huangjr
9
+ - pengyuchen
10
+ - stozuka
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2015-10-24 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: nokogiri
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Get movie information in Hsin Chu
31
+ email:
32
+ - stonegold546@gmail.com
33
+ - jr@nlplab.cc
34
+ - pengyu@gmail.com
35
+ - stozuka@gmail.com
36
+ executables:
37
+ - kandianying
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".gitignore"
42
+ - Gemfile
43
+ - LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - bin/kandianying
47
+ - kandianying.gemspec
48
+ - lib/.DS_Store
49
+ - lib/kandianying.rb
50
+ - lib/kandianying/version.rb
51
+ - lib/kandianying/vieshow.rb
52
+ homepage: https://github.com/SOAupstart2/Hsinchu_Movie
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.4.6
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Get movie information in Hsin Chu
76
+ test_files: []