afr_load 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b85fc98222a4fd67924139efacd403942b55c5b
4
+ data.tar.gz: e0c18c202161364780d070c2327c90dc2d2684ae
5
+ SHA512:
6
+ metadata.gz: d3da6fcdea49b72feb5f5fb8ac7552862222f4757a1d53874a380a4cec27a9e808ffbdef5f6667e60636eed3462d4aefeb22659896dec559db06718aa21c1e1f
7
+ data.tar.gz: 27c0bb244787aa7f833d529e908c00342a163e989c93ab735048b12fd52ae326a0854fb603636bd9cfb9e5740531217c5639f01617f6cba8566c295c15b3de7d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /lib/afr_load/afr_load.html
11
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in afr_load.gemspec
4
+ gemspec
5
+
6
+ gem 'oga', '2.3'
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # AfrLoad
2
+
3
+ 午後ローサイトのスクレイピング
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'afr_load'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install afr_load
20
+
21
+ ## Usage
22
+
23
+ AfrLoad::AfrLoad.get_schedule()
24
+
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ 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](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/iaia/afr_load. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
35
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/afr_load.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'afr_load/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "afr_load"
8
+ spec.version = AfrLoad::VERSION
9
+ spec.authors = ["iaia"]
10
+ spec.email = ["iaia72160@gmail.com"]
11
+
12
+ spec.summary = %q{Web Scraping for 午後のロードショー}
13
+ spec.description = %q{午後ローのスケジュールから、放送日、タイトル、映画に関する情報をハッシュ形式で取得します}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+
26
+ spec.add_dependency "oga"
27
+ spec.add_dependency "httpclient"
28
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "afr_load"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ require "oga"
4
+ require "httpclient"
5
+
6
+ module AfrLoad
7
+ class AfrLoad
8
+ attr_reader :programs
9
+
10
+ AFR_LOAD_URL = "http://www.tv-tokyo.co.jp/telecine/oa_afr_load/"
11
+
12
+ def initialize()
13
+ @programs = Array.new()
14
+ end
15
+ def self.get_schedule()
16
+ afr = self.new()
17
+ afr.get_schedule()
18
+ return afr.programs
19
+ end
20
+ def afr_load(file_path)
21
+ if file.blank?
22
+ document = get_schedule()
23
+ else
24
+ document = get_schedule_from_file(file_path)
25
+ end
26
+ parse(document)
27
+ end
28
+ def get_schedule()
29
+ enum = Enumerator.new do |yielder|
30
+ HTTPClient.get(AFR_LOAD_URL) do |chunk|
31
+ yielder << chunk.force_encoding("utf-8")
32
+ end
33
+ end
34
+ document = Oga.parse_html(enum)
35
+ parse(document)
36
+ return document
37
+ end
38
+ def get_schedule_from_file(file_path)
39
+ handler = File.open(file_path)
40
+ document = Oga.parse_html(handler)
41
+ parse(document)
42
+ return document
43
+ end
44
+ def parse(document)
45
+ document.xpath("//div[@id='contents']/div").each do |contents_child|
46
+ if contents_child.attribute("id") == nil
47
+ next
48
+ end
49
+ if not contents_child.attribute("id").value =~ /[0-9]{6}/
50
+ next
51
+ end
52
+ # gogo_item
53
+ contents_child.xpath("//div/div[@class='gogo_item']").each do |movie_node|
54
+ movie = Hash.new()
55
+ movie.store("on_air_date", movie_node.at_xpath("span[contains(@class, 'g_day')]").text)
56
+ data_block = movie_node.at_xpath("div[contains(@class, 'g_data_block')]")
57
+
58
+ movie.store("title_ja", data_block.at_xpath("h3/span[@class='jp']").text)
59
+ movie.store("title", data_block.at_xpath("h3/span[contains(@class, 'en')]").text)
60
+
61
+ year_country = data_block.at_xpath("div/span[@class='g_country_year']").text.split("◆")
62
+ movie.store("released_year", year_country[0])
63
+ movie.store("released_country", year_country[1])
64
+
65
+ movie.store("leading_actor", data_block.xpath("div/div/div[1]/span[2]").text)
66
+ movie.store("supporting_actor", data_block.xpath("div/div/div[2]/span[2]").text)
67
+ @programs.push(movie)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
@@ -0,0 +1,3 @@
1
+ module AfrLoad
2
+ VERSION = "0.1.0"
3
+ end
data/lib/afr_load.rb ADDED
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ require "afr_load/version"
4
+ require "afr_load/afr_load"
5
+
6
+ module AfrLoad
7
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: afr_load
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - iaia
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: oga
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httpclient
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: "午後ローのスケジュールから、放送日、タイトル、映画に関する情報をハッシュ形式で取得します"
84
+ email:
85
+ - iaia72160@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - README.md
96
+ - Rakefile
97
+ - afr_load.gemspec
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/afr_load.rb
101
+ - lib/afr_load/afr_load.rb
102
+ - lib/afr_load/version.rb
103
+ homepage: ''
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.5.1
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Web Scraping for 午後のロードショー
127
+ test_files: []