meiriyigua 0.0.4 → 0.0.5
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 +8 -8
- data/lib/meiriyigua.rb +25 -5
- data/lib/meiriyigua/post_client_two.rb +53 -0
- data/lib/meiriyigua/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
MDg4NzVlM2MwOGU3Nzg5YTIxMzllZGU4OGZlNmYzYmY4MzViOWM5Nw==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NDIxZmI2OTc3NzRhZjI0NzcxYmU0MDg3OWQ5NzcyODE0YWI5NDRmNg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
M2JiZjQyNzUyNDRkNmRiOGVkYjhhMTNkMTJlNDE3ZGYyNGNlNDNjYTI1NWYy
|
|
10
|
+
YzIyN2ExNWZhMjQ2N2RkYmU2NzQxNjE0ZjI4YjZlNDQ2MjIxMmY3MzkzNjU1
|
|
11
|
+
NDBlZDNmZmJkNDUzZDkyZjljZDE1Y2IyYWMyYTBjZTc1ODUwMzA=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
ODNmYzY2ZDZlZWNmMDU1NGVlZDU1MmNiMzQ1ODhmZjRhNDk4YTkxOTg0YTRj
|
|
14
|
+
ZTNhOWEwYjJjNzRhOWQyNzA1Y2U4YTNjMTQ4MmY4ODZmNjZlZjhlZTI5Yjdm
|
|
15
|
+
Y2Y3Y2RhZmQxMTI1MDM1Y2QxNGIzMDFkZDA0ZTZmYTBlOGVlMTg=
|
data/lib/meiriyigua.rb
CHANGED
|
@@ -5,10 +5,24 @@ require "meiriyigua/list_crawl"
|
|
|
5
5
|
require "meiriyigua/detail_crawl"
|
|
6
6
|
require "meiriyigua/baidu_crawl"
|
|
7
7
|
require "meiriyigua/post_client"
|
|
8
|
+
require "meiriyigua/post_client_two"
|
|
8
9
|
require "meiriyigua/models"
|
|
9
10
|
|
|
10
11
|
module Meiriyigua
|
|
11
12
|
def run
|
|
13
|
+
@type = 1
|
|
14
|
+
__run
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def run_two
|
|
18
|
+
@type = 2
|
|
19
|
+
__run
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
def __run
|
|
24
|
+
Thread.abort_on_exception = true
|
|
25
|
+
|
|
12
26
|
while true
|
|
13
27
|
begin
|
|
14
28
|
((Meiriyigua::Models::UrlRecord.all(baidu_at: nil) | Meiriyigua::Models::UrlRecord.all(publish_at: nil)) & Meiriyigua::Models::UrlRecord.all(:detail_at.lt => (Date.today - 7))).each do |url_record|
|
|
@@ -16,6 +30,8 @@ module Meiriyigua
|
|
|
16
30
|
url_record.destroy
|
|
17
31
|
end
|
|
18
32
|
|
|
33
|
+
Meiriyigua::Models::PageRecord.all(url_record: {:publish_at.not => nil}).destroy!
|
|
34
|
+
|
|
19
35
|
threads = []
|
|
20
36
|
threads << Thread.new do
|
|
21
37
|
list_crawl = ListCrawl.new
|
|
@@ -30,19 +46,23 @@ module Meiriyigua
|
|
|
30
46
|
sleep(Meiriyigua::Config.update_time.to_i)
|
|
31
47
|
end
|
|
32
48
|
threads << Thread.new do
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
if @type == 1
|
|
50
|
+
post_client = PostClient.new
|
|
51
|
+
post_client.run
|
|
52
|
+
else
|
|
53
|
+
post_client = PostClientTwo.new
|
|
54
|
+
post_client.run
|
|
55
|
+
end
|
|
35
56
|
sleep(Meiriyigua::Config.post_time.to_i)
|
|
36
57
|
end
|
|
37
58
|
threads.each { |thr| thr.join }
|
|
38
59
|
|
|
39
60
|
rescue
|
|
40
61
|
puts "出错了 #{$!.message}\n#{$!.backtrace.join("\n")}"
|
|
62
|
+
threads.each { |thr| thr.exit rescue nil }
|
|
41
63
|
end
|
|
42
64
|
sleep 60*10
|
|
43
65
|
end
|
|
44
66
|
end
|
|
45
|
-
module_function :run
|
|
67
|
+
module_function :run, :run_two, :__run
|
|
46
68
|
end
|
|
47
|
-
|
|
48
|
-
Meiriyigua.run
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
require 'meiriyigua/models'
|
|
3
|
+
require 'meiriyigua/config'
|
|
4
|
+
require 'meiriyigua/crawl_client'
|
|
5
|
+
|
|
6
|
+
module Meiriyigua
|
|
7
|
+
class PostClientTwo
|
|
8
|
+
include Meiriyigua::Models
|
|
9
|
+
|
|
10
|
+
ZHS = 0x4e00..0x9fff
|
|
11
|
+
|
|
12
|
+
attr_reader :category_ids
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@agent = CrawlClient.create_agent
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def run
|
|
19
|
+
today_count = UrlRecord.count(:publish_at.gte => Date.today)
|
|
20
|
+
|
|
21
|
+
if today_count >= Meiriyigua::Config.day_num
|
|
22
|
+
return
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
UrlRecord.all(:baidu_at.not => nil, :publish_at => nil).each do |url_record|
|
|
26
|
+
today_count += 1
|
|
27
|
+
if today_count >= Meiriyigua::Config.day_num
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
page_record = url_record.page_record
|
|
32
|
+
post_news(page_record)
|
|
33
|
+
url_record.publish_at = Time.now
|
|
34
|
+
url_record.save
|
|
35
|
+
print "发布 #{url_record.url} "
|
|
36
|
+
puts "成功"
|
|
37
|
+
sleep Meiriyigua::Config.post_time.to_i
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def post_news(page_record)
|
|
42
|
+
post_params = {}
|
|
43
|
+
post_params['A'] = "#{page_record.category}最新版辅助外挂免费下载 #{page_record.title}"
|
|
44
|
+
downloads = page_record.downloads.split('#!#')
|
|
45
|
+
post_params['xiadizhi'] = downloads[0]
|
|
46
|
+
post_params['xiadizhi2'] = downloads[1]
|
|
47
|
+
post_params['tjiao'] = 'opop'
|
|
48
|
+
post_params['editorValue'] = "<pre>#{page_record.content} \r\n\r\n #{page_record.baidu_intro}</pre>"
|
|
49
|
+
@agent.post("http://#{Meiriyigua::Config.site_host}/ti.php", post_params)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
data/lib/meiriyigua/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: meiriyigua
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mangege
|
|
@@ -114,6 +114,7 @@ files:
|
|
|
114
114
|
- lib/meiriyigua/list_crawl.rb
|
|
115
115
|
- lib/meiriyigua/models.rb
|
|
116
116
|
- lib/meiriyigua/post_client.rb
|
|
117
|
+
- lib/meiriyigua/post_client_two.rb
|
|
117
118
|
- lib/meiriyigua/version.rb
|
|
118
119
|
- meiriyigua.gemspec
|
|
119
120
|
- set.yml.example
|