spider_rails 1.0.0 → 2.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30ae9908f3168c9e14939e77e5d3744c46fd4b34
4
- data.tar.gz: 76f7a134465a6b509c16a3a63a743b9a62fdd698
3
+ metadata.gz: 3d0b2b6ab974d2ceeaaaea749b23862f67cd0d83
4
+ data.tar.gz: cb3f0897927374a6a73ca6bd9bf1293d855e30c9
5
5
  SHA512:
6
- metadata.gz: 26a0739c6bb166d7642104b6ad56d40356ca854c83c2345dcc2a964da667ea0f5359e038778bbcc3548760b51a9891c34cc80c4a5ec38a671e52c3176fbecb79
7
- data.tar.gz: d5af6447509f0a8959ac060e2424c482216ab32792cfcef9c107366cc1f8f1bc813dabcf388e270a11658ebb3ce5ce98afb62bf8580558fbc72ae32f1487410b
6
+ metadata.gz: cbca2addfc03890b7974184a4bdfe6839ffb2c883b62fad49eefd3cc13d40946248b17a381924412d764b9ba55dc2f2b0d2620398b73f96f2888644fbdc115f1
7
+ data.tar.gz: 73712ec4cf1c5857526da925236e0a00d88036500571f159fa35c1b2d07010bdc4da42c4683f5ef58033fbadd6ddfdcd6ea62295dc6769fff5b47f1f34800848
@@ -38,9 +38,9 @@ module Spider
38
38
 
39
39
  def get_card keyword
40
40
  @card = Hash.new
41
- @b = open_browser "https://www.google.com.hk/search?newwindow=1&safe=strict&q=#{keyword}+define&oq=#{keyword}+define"
41
+ @env = open_browser "https://www.google.com.hk/search?newwindow=1&safe=strict&q=#{keyword}+define&oq=#{keyword}+define"
42
42
 
43
- doc = Nokogiri::HTML.parse @b.html
43
+ doc = Nokogiri::HTML.parse @env.html
44
44
 
45
45
  GoogleDict.alias_methods :card, :voice, :word, :get_content
46
46
  card(doc, 'li.dct') do |c|
@@ -51,7 +51,7 @@ module Spider
51
51
  get_explain(c)
52
52
  end
53
53
 
54
- @b.close
54
+ @env.close
55
55
  @card.delete(0)
56
56
  @card
57
57
  end
@@ -81,7 +81,7 @@ module Spider
81
81
  #end
82
82
 
83
83
  def element?(selector, &block)
84
- e = @b.element(css: selector)
84
+ e = @env.element(css: selector)
85
85
  if yield e
86
86
  else
87
87
  'element is nil'
@@ -2,9 +2,9 @@ module Spider
2
2
  class JiYing < Common
3
3
  attr_accessor :ani
4
4
 
5
- def initialize browser
5
+ def initialize environment
6
6
  @ani = Hash.new
7
- @b = browser
7
+ @env = environment
8
8
  end
9
9
 
10
10
  def full_site
@@ -19,18 +19,19 @@ module Spider
19
19
  end
20
20
 
21
21
  def final_page
22
- @b.element(css: '.title h2 a').text[/\(.+\)/].gsub!(/\(|\)/, '').to_i/100 + 1
22
+ @env.element(css: '.title h2 a').text[/\(.+\)/].gsub!(/\(|\)/, '').to_i/100 + 1
23
23
  end
24
24
 
25
25
  def full_page page_num
26
- @b.goto "http://bt.ktxp.com/search.php?keyword=%E8%AF%B8%E7%A5%9E&sort_id=28&field=title&order=&page=#{page_num}"
27
- html = Nokogiri::HTML.parse @b.html
26
+ @env.goto "http://bt.ktxp.com/search.php?keyword=%E8%AF%B8%E7%A5%9E&sort_id=28&field=title&order=&page=#{page_num}"
27
+ html = Nokogiri::HTML.parse @env.html
28
28
  html.css('ltext').each do |td|
29
29
  single(td)
30
30
  end
31
31
  end
32
32
 
33
33
  def single element
34
+ get(element)
34
35
  single_filter
35
36
  save Ani
36
37
  end
@@ -54,7 +55,7 @@ module Spider
54
55
  @ani = nil
55
56
  end
56
57
 
57
- @ani[:torrent].prepend('http://bt.ktxp.com/')
58
+ @ani[:torrent].prepend('http://bt.ktxp.com')
58
59
  end
59
60
  end
60
61
  end
@@ -1,3 +1,3 @@
1
1
  module SpiderRails
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -158,3 +158,95 @@ JiYingTest: test_save
158
158
   (0.2ms) RELEASE SAVEPOINT active_record_1
159
159
   (0.2ms) SELECT COUNT(*) FROM "anis"
160
160
   (0.3ms) rollback transaction
161
+  (0.3ms) begin transaction
162
+ ---------------------------
163
+ JiYingTest: test_final_page
164
+ ---------------------------
165
+  (0.1ms) rollback transaction
166
+  (0.1ms) begin transaction
167
+ --------------------------
168
+ JiYingTest: test_full_page
169
+ --------------------------
170
+  (0.1ms) rollback transaction
171
+  (0.1ms) begin transaction
172
+ --------------------------
173
+ JiYingTest: test_full_site
174
+ --------------------------
175
+  (0.4ms) rollback transaction
176
+  (0.1ms) begin transaction
177
+ --------------------
178
+ JiYingTest: test_get
179
+ --------------------
180
+  (0.2ms) rollback transaction
181
+  (0.1ms) begin transaction
182
+ ---------------------
183
+ JiYingTest: test_save
184
+ ---------------------
185
+  (0.1ms) SELECT COUNT(*) FROM "anis"
186
+  (0.1ms) SAVEPOINT active_record_1
187
+ SQL (2.7ms) INSERT INTO "anis" ("created_at", "title", "torrent", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sun, 14 Jul 2013 14:55:59 UTC +00:00], ["title", "魔法"], ["torrent", "http://baidu.com"], ["updated_at", Sun, 14 Jul 2013 14:55:59 UTC +00:00]]
188
+  (0.1ms) RELEASE SAVEPOINT active_record_1
189
+  (0.1ms) SELECT COUNT(*) FROM "anis"
190
+  (0.2ms) rollback transaction
191
+  (0.1ms) begin transaction
192
+ ----------------------------------------------------------
193
+ JiYingTest: test_single_filter_animation_name_include_"外挂"
194
+ ----------------------------------------------------------
195
+  (0.1ms) rollback transaction
196
+  (0.1ms) begin transaction
197
+ --------------------------------------------------------------------
198
+ JiYingTest: test_torrent_url_should_has_full_text_when_single_finish
199
+ --------------------------------------------------------------------
200
+  (0.1ms) rollback transaction
201
+  (0.1ms) begin transaction
202
+ ---------------------------
203
+ SpiderRailsTest: test_truth
204
+ ---------------------------
205
+  (0.1ms) rollback transaction
206
+  (0.5ms) begin transaction
207
+ ---------------------------
208
+ JiYingTest: test_final_page
209
+ ---------------------------
210
+  (0.4ms) begin transaction
211
+ ---------------------------
212
+ JiYingTest: test_final_page
213
+ ---------------------------
214
+  (0.7ms) rollback transaction
215
+  (0.4ms) begin transaction
216
+ --------------------------
217
+ JiYingTest: test_full_page
218
+ --------------------------
219
+  (1.3ms) rollback transaction
220
+  (0.3ms) begin transaction
221
+ --------------------------
222
+ JiYingTest: test_full_site
223
+ --------------------------
224
+  (0.5ms) begin transaction
225
+ --------------------------------------------------------------------
226
+ JiYingTest: test_torrent_url_should_has_full_text_when_single_finish
227
+ --------------------------------------------------------------------
228
+  (0.5ms) begin transaction
229
+ --------------------------------------------------------------------
230
+ JiYingTest: test_torrent_url_should_has_full_text_when_single_finish
231
+ --------------------------------------------------------------------
232
+  (0.4ms) rollback transaction
233
+  (0.5ms) begin transaction
234
+ --------------------------------------------------------------------
235
+ JiYingTest: test_torrent_url_should_has_full_text_when_single_finish
236
+ --------------------------------------------------------------------
237
+  (0.5ms) begin transaction
238
+ --------------------------------------------------------------------
239
+ JiYingTest: test_torrent_url_should_has_full_text_when_single_finish
240
+ --------------------------------------------------------------------
241
+  (0.3ms) SAVEPOINT active_record_1
242
+ SQL (3.1ms) INSERT INTO "anis" ("created_at", "title", "torrent", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sun, 14 Jul 2013 15:01:20 UTC +00:00], ["title", "【诸神字幕组】[冰菓/冰果 Hyouka][01-22合集+OAD][720P][外挂中日文字幕][BD-MP4]"], ["torrent", "http://bt.ktxp.com//down/1373543782/24e913ee8f4817b3e78fc530a62cf183e1814a31.torrent"], ["updated_at", Sun, 14 Jul 2013 15:01:20 UTC +00:00]]
243
+  (0.2ms) RELEASE SAVEPOINT active_record_1
244
+  (0.3ms) rollback transaction
245
+  (0.4ms) begin transaction
246
+ --------------------------------------------------------------------
247
+ JiYingTest: test_torrent_url_should_has_full_text_when_single_finish
248
+ --------------------------------------------------------------------
249
+  (0.2ms) SAVEPOINT active_record_1
250
+ SQL (2.8ms) INSERT INTO "anis" ("created_at", "title", "torrent", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sun, 14 Jul 2013 15:08:35 UTC +00:00], ["title", "【诸神字幕组】[冰菓/冰果 Hyouka][01-22合集+OAD][720P][外挂中日文字幕][BD-MP4]"], ["torrent", "http://bt.ktxp.com/down/1373543782/24e913ee8f4817b3e78fc530a62cf183e1814a31.torrent"], ["updated_at", Sun, 14 Jul 2013 15:08:35 UTC +00:00]]
251
+  (0.2ms) RELEASE SAVEPOINT active_record_1
252
+  (0.3ms) rollback transaction
data/test/ji_ying_test.rb CHANGED
@@ -5,15 +5,15 @@ class JiYingTest < ActiveSupport::TestCase
5
5
 
6
6
  def setup
7
7
  Browser.close_all_chromes
8
- @b = Browser.open_browser "http://bt.ktxp.com/search.php?keyword=%E8%AF%B8%E7%A5%9E&sort_id=28&field=title&order=&page=1"
9
- @jy = Spider::JiYing.new @b
8
+ @env = Browser.open_browser "http://bt.ktxp.com/search.php?keyword=%E8%AF%B8%E7%A5%9E&sort_id=28&field=title&order=&page=1"
9
+ @jy = Spider::JiYing.new @env
10
10
 
11
- html = Nokogiri::HTML.parse @b.html
11
+ html = Nokogiri::HTML.parse @env.html
12
12
  @e = html.css('.ltext').first
13
13
  end
14
14
 
15
15
  def teardown
16
- @b.close
16
+ @env.close
17
17
  end
18
18
 
19
19
  test 'get' do
@@ -38,7 +38,8 @@ class JiYingTest < ActiveSupport::TestCase
38
38
  end
39
39
 
40
40
  test 'torrent url should has full text when single finish' do
41
- assert_match(/http:\/\/bt\.ktxp\.com\/down.*/, @jy.ani[:torrent])
41
+ @jy.single @e
42
+ assert_match(/http\:\/\/bt.ktxp.com\/down.*/, @jy.ani[:torrent])
42
43
  end
43
44
 
44
45
  test 'full_page' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spider_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhuxingruo