brandeins 0.2.2 → 0.3.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -1
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +7 -4
- data/Gemfile.lock +47 -21
- data/NOTES.md +6 -0
- data/Rakefile +15 -8
- data/bin/brandeins +3 -1
- data/brandeins.gemspec +0 -1
- data/lib/brandeins.rb +3 -5
- data/lib/brandeins/cli.rb +46 -34
- data/lib/brandeins/config.rb +18 -0
- data/lib/brandeins/kiosk.rb +100 -0
- data/lib/brandeins/merger/external/base.rb +16 -6
- data/lib/brandeins/merger/pdf_tools.rb +3 -6
- data/lib/brandeins/pages/archive.rb +91 -0
- data/lib/brandeins/pages/article.rb +37 -0
- data/lib/brandeins/pages/cover.rb +67 -0
- data/lib/brandeins/pages/magazine.rb +149 -0
- data/lib/brandeins/utils/cli_option_parser.rb +40 -0
- data/lib/brandeins/utils/cli_output.rb +100 -0
- data/lib/brandeins/utils/fetcher.rb +115 -0
- data/lib/brandeins/utils/merger.rb +41 -0
- data/lib/brandeins/version.rb +1 -1
- data/rubocop-todo.yml +141 -0
- data/spec/lib/brandeins/kiosk_spec.rb +66 -0
- data/spec/lib/brandeins/pages/archive_spec.rb +40 -0
- data/spec/lib/brandeins/pages/article_spec.rb +23 -0
- data/spec/lib/brandeins/pages/magazine_spec.rb +91 -0
- data/spec/lib/brandeins/utils/fetcher_spec.rb +8 -0
- data/spec/lib/brandeins_spec.rb +19 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/capture_stdout.rb +12 -0
- data/spec/support/fixtures/archive.html +2365 -0
- data/spec/support/fixtures/artikel-masskonfektion-aus-plastik.html +254 -0
- data/spec/support/fixtures/artikel-schauspieler-daenemark.html +247 -0
- data/{test_support → spec/support}/fixtures/cover.jpg +0 -0
- data/spec/support/fixtures/editorial.html +236 -0
- data/spec/support/fixtures/just-a.pdf +0 -0
- data/spec/support/fixtures/magazine-1-2013.html +242 -0
- data/spec/support/fixtures/magazine-cover-fallback.html +1610 -0
- data/spec/support/fixtures/magazine-with-cover.html +1416 -0
- metadata +68 -61
- data/.rvmrc +0 -48
- data/lib/brandeins/downloader.rb +0 -111
- data/lib/brandeins/errors.rb +0 -5
- data/lib/brandeins/parser/archive_site.rb +0 -54
- data/lib/brandeins/parser/article_site.rb +0 -26
- data/lib/brandeins/parser/magazine_site.rb +0 -49
- data/lib/brandeins/setup.rb +0 -38
- data/specs/brandeins_spec.rb +0 -52
- data/specs/spec_helper.rb +0 -1
- data/test/brandeins_test.rb +0 -65
- data/test/helper.rb +0 -1
- data/test_support/capture_stdout.rb +0 -12
- data/test_support/fixtures/brandeins_archiv.html +0 -50
metadata
CHANGED
@@ -1,78 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brandeins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0.pre
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Gregory Igelmund
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: thor
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
24
|
+
- - '>='
|
44
25
|
- !ruby/object:Gem::Version
|
45
26
|
version: '0'
|
46
27
|
- !ruby/object:Gem::Dependency
|
47
28
|
name: nokogiri
|
48
29
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
30
|
requirements:
|
51
|
-
- -
|
31
|
+
- - '>='
|
52
32
|
- !ruby/object:Gem::Version
|
53
33
|
version: '0'
|
54
34
|
type: :runtime
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
37
|
requirements:
|
59
|
-
- -
|
38
|
+
- - '>='
|
60
39
|
- !ruby/object:Gem::Version
|
61
40
|
version: '0'
|
62
41
|
- !ruby/object:Gem::Dependency
|
63
42
|
name: prawn
|
64
43
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
44
|
requirements:
|
67
|
-
- -
|
45
|
+
- - '>='
|
68
46
|
- !ruby/object:Gem::Version
|
69
47
|
version: '0'
|
70
48
|
type: :runtime
|
71
49
|
prerelease: false
|
72
50
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
51
|
requirements:
|
75
|
-
- -
|
52
|
+
- - '>='
|
76
53
|
- !ruby/object:Gem::Version
|
77
54
|
version: '0'
|
78
55
|
description: BrandEins gem offers a download command to download a specific or all
|
@@ -85,9 +62,13 @@ extensions: []
|
|
85
62
|
extra_rdoc_files: []
|
86
63
|
files:
|
87
64
|
- .gitignore
|
88
|
-
- .
|
65
|
+
- .rspec
|
66
|
+
- .rubocop.yml
|
67
|
+
- .ruby-version
|
68
|
+
- .travis.yml
|
89
69
|
- Gemfile
|
90
70
|
- Gemfile.lock
|
71
|
+
- NOTES.md
|
91
72
|
- README.md
|
92
73
|
- Rakefile
|
93
74
|
- TODOS.md
|
@@ -96,55 +77,81 @@ files:
|
|
96
77
|
- brandeins.gemspec
|
97
78
|
- lib/brandeins.rb
|
98
79
|
- lib/brandeins/cli.rb
|
99
|
-
- lib/brandeins/
|
100
|
-
- lib/brandeins/
|
80
|
+
- lib/brandeins/config.rb
|
81
|
+
- lib/brandeins/kiosk.rb
|
101
82
|
- lib/brandeins/merger/external/base.rb
|
102
83
|
- lib/brandeins/merger/external/ghostscript_windows.rb
|
103
84
|
- lib/brandeins/merger/external/pdftk.rb
|
104
85
|
- lib/brandeins/merger/pdf_tools.rb
|
105
|
-
- lib/brandeins/
|
106
|
-
- lib/brandeins/
|
107
|
-
- lib/brandeins/
|
108
|
-
- lib/brandeins/
|
86
|
+
- lib/brandeins/pages/archive.rb
|
87
|
+
- lib/brandeins/pages/article.rb
|
88
|
+
- lib/brandeins/pages/cover.rb
|
89
|
+
- lib/brandeins/pages/magazine.rb
|
90
|
+
- lib/brandeins/utils/cli_option_parser.rb
|
91
|
+
- lib/brandeins/utils/cli_output.rb
|
92
|
+
- lib/brandeins/utils/fetcher.rb
|
93
|
+
- lib/brandeins/utils/merger.rb
|
109
94
|
- lib/brandeins/version.rb
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
95
|
+
- rubocop-todo.yml
|
96
|
+
- spec/lib/brandeins/kiosk_spec.rb
|
97
|
+
- spec/lib/brandeins/pages/archive_spec.rb
|
98
|
+
- spec/lib/brandeins/pages/article_spec.rb
|
99
|
+
- spec/lib/brandeins/pages/magazine_spec.rb
|
100
|
+
- spec/lib/brandeins/utils/fetcher_spec.rb
|
101
|
+
- spec/lib/brandeins_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
- spec/support/capture_stdout.rb
|
104
|
+
- spec/support/fixtures/archive.html
|
105
|
+
- spec/support/fixtures/artikel-masskonfektion-aus-plastik.html
|
106
|
+
- spec/support/fixtures/artikel-schauspieler-daenemark.html
|
107
|
+
- spec/support/fixtures/cover.jpg
|
108
|
+
- spec/support/fixtures/editorial.html
|
109
|
+
- spec/support/fixtures/just-a.pdf
|
110
|
+
- spec/support/fixtures/magazine-1-2013.html
|
111
|
+
- spec/support/fixtures/magazine-cover-fallback.html
|
112
|
+
- spec/support/fixtures/magazine-with-cover.html
|
117
113
|
homepage: http://www.grekko.de
|
118
114
|
licenses: []
|
119
|
-
|
120
|
-
|
115
|
+
metadata: {}
|
116
|
+
post_install_message: |+
|
117
|
+
BrandEins gem runs on windows and os x and depends on pdftk/ghostscript to merge downloaded pdfs.
|
118
|
+
Run `brandeins setup` to check if all requirements are met and for informations on how to meet them.
|
121
119
|
|
122
|
-
Run `brandeins setup` to check if all requirements are met and for informations
|
123
|
-
on how to meet them.
|
124
|
-
|
125
|
-
|
126
|
-
'
|
127
120
|
rdoc_options: []
|
128
121
|
require_paths:
|
129
122
|
- lib
|
130
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
124
|
requirements:
|
133
|
-
- -
|
125
|
+
- - '>='
|
134
126
|
- !ruby/object:Gem::Version
|
135
127
|
version: '0'
|
136
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
129
|
requirements:
|
139
|
-
- -
|
130
|
+
- - '>'
|
140
131
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
132
|
+
version: 1.3.1
|
142
133
|
requirements: []
|
143
134
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.
|
135
|
+
rubygems_version: 2.1.11
|
145
136
|
signing_key:
|
146
|
-
specification_version:
|
137
|
+
specification_version: 4
|
147
138
|
summary: BrandEins gem allows you to download past volumes of the Brand Eins magazine
|
148
139
|
test_files:
|
149
|
-
-
|
150
|
-
-
|
140
|
+
- spec/lib/brandeins/kiosk_spec.rb
|
141
|
+
- spec/lib/brandeins/pages/archive_spec.rb
|
142
|
+
- spec/lib/brandeins/pages/article_spec.rb
|
143
|
+
- spec/lib/brandeins/pages/magazine_spec.rb
|
144
|
+
- spec/lib/brandeins/utils/fetcher_spec.rb
|
145
|
+
- spec/lib/brandeins_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
- spec/support/capture_stdout.rb
|
148
|
+
- spec/support/fixtures/archive.html
|
149
|
+
- spec/support/fixtures/artikel-masskonfektion-aus-plastik.html
|
150
|
+
- spec/support/fixtures/artikel-schauspieler-daenemark.html
|
151
|
+
- spec/support/fixtures/cover.jpg
|
152
|
+
- spec/support/fixtures/editorial.html
|
153
|
+
- spec/support/fixtures/just-a.pdf
|
154
|
+
- spec/support/fixtures/magazine-1-2013.html
|
155
|
+
- spec/support/fixtures/magazine-cover-fallback.html
|
156
|
+
- spec/support/fixtures/magazine-with-cover.html
|
157
|
+
has_rdoc:
|
data/.rvmrc
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3-p286@brandeins"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.16.19 (stable)" # 1.10.1 seams as a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
-
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
-
else
|
29
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
-
rvm --create "$environment_id" || {
|
31
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
-
return 1
|
33
|
-
}
|
34
|
-
fi
|
35
|
-
|
36
|
-
# If you use bundler, this might be useful to you:
|
37
|
-
# if [[ -s Gemfile ]] && {
|
38
|
-
# ! builtin command -v bundle >/dev/null ||
|
39
|
-
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
-
# }
|
41
|
-
# then
|
42
|
-
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
-
# gem install bundler
|
44
|
-
# fi
|
45
|
-
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
-
# then
|
47
|
-
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
-
# fi
|
data/lib/brandeins/downloader.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'brandeins/parser/article_site'
|
3
|
-
require 'brandeins/parser/magazine_site'
|
4
|
-
require 'brandeins/parser/archive_site'
|
5
|
-
require 'brandeins/merger/pdf_tools'
|
6
|
-
require 'net/http'
|
7
|
-
require 'prawn'
|
8
|
-
|
9
|
-
module BrandEins
|
10
|
-
class Downloader
|
11
|
-
|
12
|
-
def initialize(path, opts = {})
|
13
|
-
$BE_VERBOSE = !!opts[:verbose]
|
14
|
-
|
15
|
-
@url = 'http://www.brandeins.de'
|
16
|
-
@dl_dir = path
|
17
|
-
@tmp_dir = @dl_dir + '/brand-eins-tmp'
|
18
|
-
@pdftool = BrandEins::Merger::PdfTools.get_pdf_tool
|
19
|
-
@archive = BrandEins::Parser::ArchiveSite.new(@url)
|
20
|
-
create_tmp_dirs
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_magazines_of_year(year = 2000)
|
24
|
-
puts "Getting all brand eins magazines of #{year}. This may take a while..." if $BE_VERBOSE
|
25
|
-
magazine_links_per_year = @archive.get_magazine_links_by_year(year)
|
26
|
-
magazine_links_per_year.each_with_index do |magazine_link, index|
|
27
|
-
volume = index+1
|
28
|
-
puts "Parsing Volume #{volume} of #{year}" if $BE_VERBOSE
|
29
|
-
target_pdf = pdf_filename(year, volume)
|
30
|
-
get_magazine_by_link(magazine_link, target_pdf, year, volume)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_magazine(year = 2000, volume = 1)
|
35
|
-
puts "Parsing Volume #{volume} of #{year}" if $BE_VERBOSE
|
36
|
-
target_pdf = pdf_filename(year, volume)
|
37
|
-
magazine_links = @archive.get_magazine_links_by_year(year)
|
38
|
-
magazine_link = magazine_links[volume-1]
|
39
|
-
get_magazine_by_link(magazine_link, target_pdf, year, volume)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
def create_tmp_dirs
|
44
|
-
FileUtils.mkdir_p @tmp_dir unless File.directory?(@tmp_dir)
|
45
|
-
end
|
46
|
-
|
47
|
-
def create_cover_pdf(year, volume)
|
48
|
-
puts "Creating cover for Volume #{volume} of #{year}" if $BE_VERBOSE
|
49
|
-
cover = @archive.get_magazine_cover(year, volume)
|
50
|
-
cover_title = cover[:title]
|
51
|
-
cover_img_url = cover[:img_url]
|
52
|
-
cover_img_file = @tmp_dir + "/cover-#{year}-#{volume}.jpg"
|
53
|
-
cover_pdf_file = @tmp_dir + "/cover-#{year}-#{volume}.pdf"
|
54
|
-
|
55
|
-
puts "Downloading cover image from #{cover_img_url} to #{cover_img_file}" if $BE_VERBOSE
|
56
|
-
IO.binwrite(cover_img_file, Net::HTTP.get(URI(cover_img_url)))
|
57
|
-
|
58
|
-
puts "Creating cover pdf #{cover_pdf_file} from #{cover_img_file}" if $BE_VERBOSE
|
59
|
-
Prawn::Document.generate(cover_pdf_file) do |pdf|
|
60
|
-
pdf.text "<font size='18'><b>" + cover_title + "</b></font>", :align => :center, :inline_format => true
|
61
|
-
pdf.image cover_img_file, :position => :center, :vposition => :center
|
62
|
-
end
|
63
|
-
|
64
|
-
return cover_pdf_file
|
65
|
-
end
|
66
|
-
|
67
|
-
def get_magazine_by_link(target_magazine_link, target_pdf, year, volume)
|
68
|
-
pdf_links = @archive.magazine_pdf_links(target_magazine_link)
|
69
|
-
pdf_files = download(pdf_links)
|
70
|
-
|
71
|
-
pdf_cover = create_cover_pdf(year, volume)
|
72
|
-
pdf_files = pdf_files.unshift(pdf_cover)
|
73
|
-
|
74
|
-
if @pdftool
|
75
|
-
target_pdf_path = "#{@dl_dir}/#{target_pdf}"
|
76
|
-
@pdftool.merge_pdf_files(pdf_files, target_pdf_path) && cleanup
|
77
|
-
else
|
78
|
-
puts 'brandeins wont merge the single pdf files since it didnt find an appropriate pdf tool' if $BE_VERBOSE
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def pdf_filename(year, volume)
|
83
|
-
"Brand-Eins-#{year}-#{volume}.pdf"
|
84
|
-
end
|
85
|
-
|
86
|
-
def download(pdf_links)
|
87
|
-
pdf_links.each_with_object([]) do |pdf_link, pdf_files|
|
88
|
-
pdf_filename = @tmp_dir + '/' + File.basename(pdf_link)
|
89
|
-
pdf_url = pdf_link
|
90
|
-
download_pdf(pdf_url, pdf_filename)
|
91
|
-
pdf_files << pdf_filename
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def download_pdf(pdf_url, pdf_filename)
|
96
|
-
if File.exists? pdf_filename
|
97
|
-
puts "File #{pdf_filename} seems to be already downloaded" if $BE_VERBOSE
|
98
|
-
return true
|
99
|
-
end
|
100
|
-
|
101
|
-
puts "Downloading PDF from #{pdf_url} to #{pdf_filename}" if $BE_VERBOSE
|
102
|
-
IO.binwrite(pdf_filename, Net::HTTP.get(URI(pdf_url)))
|
103
|
-
end
|
104
|
-
|
105
|
-
def cleanup
|
106
|
-
FileUtils.rm_r @tmp_dir
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
data/lib/brandeins/errors.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
module BrandEins
|
6
|
-
module Parser
|
7
|
-
class ArchiveSite
|
8
|
-
|
9
|
-
def initialize(base_url, opts = {})
|
10
|
-
@base_url = base_url
|
11
|
-
@archive_url = @base_url + "/archiv.html"
|
12
|
-
if html = opts[:html]
|
13
|
-
@doc = Nokogiri::HTML(html)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def doc
|
18
|
-
@doc || @doc = Nokogiri::HTML(Net::HTTP.get(URI(@archive_url)))
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_magazine_links_by_year(year = 2000)
|
22
|
-
puts "Loading Magazine from year #{year}" if $BE_VERBOSE
|
23
|
-
magazine_nodes_with_meta = doc.css(".jahrgang-#{year} ul li")
|
24
|
-
magazine_nodes_with_meta.each_with_object([]) do |node, links|
|
25
|
-
if node['id'].nil? then
|
26
|
-
link = node.css('a')
|
27
|
-
if link[0].nil? then
|
28
|
-
next
|
29
|
-
end
|
30
|
-
href = link[0]['href']
|
31
|
-
links << @base_url + '/' + href
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_magazine_cover(year, volume)
|
37
|
-
title = doc.css("#month_detail_#{year}_#{volume} .titel").children[0].to_s
|
38
|
-
img_url = ''
|
39
|
-
doc.css("#month_detail_#{year}_#{volume} .cover a img").each do |node|
|
40
|
-
img_url = node['src']
|
41
|
-
end
|
42
|
-
return { :title => title, :img_url => @base_url + '/' + img_url }
|
43
|
-
end
|
44
|
-
|
45
|
-
def magazine_pdf_links(url)
|
46
|
-
magazine = BrandEins::Parser::MagazineSite.new(url, @base_url)
|
47
|
-
magazine.get_magazine_pdf_links
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
module BrandEins
|
6
|
-
module Parser
|
7
|
-
class ArticleSite
|
8
|
-
|
9
|
-
def initialize(url)
|
10
|
-
@url = url
|
11
|
-
end
|
12
|
-
|
13
|
-
def doc
|
14
|
-
@doc || @doc = Nokogiri::HTML(Net::HTTP.get(URI(@url)))
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_pdf_link
|
18
|
-
puts "Parsing Article: #{@url}" if $BE_VERBOSE
|
19
|
-
link = doc.css("div#sidebar ul li#downloaden a")
|
20
|
-
link[0] and link[0]['href']
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|