wx_ext 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/wx_ext/sougou_weixin.rb +19 -0
- data/lib/wx_ext/version.rb +1 -1
- data/lib/wx_ext.rb +10 -3
- data/spec/wx_ext/sougou_weixin_spec.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bc728f6d9fa05657b9ea77a14be415b1da612e9
|
4
|
+
data.tar.gz: 3c78fc17004bb1f828c9bae82faf59e989a3d635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9cae7ea78c641aadab551b1399ac880d994d941dcb0ffbc125e976614340d7036a5c6272cd1c571677fbc692b1d78ef6dfb42eeb1fe712c42baf55b7b78a548
|
7
|
+
data.tar.gz: 0b9e47830b57aa31733e98915c9ea1d7ff4e1953b578229a6112cbcb647493841f892a810313f24ed5904905f7f0a714e858e4e6946265b92b58170dc25adb21
|
data/README.md
CHANGED
data/lib/wx_ext/sougou_weixin.rb
CHANGED
@@ -70,5 +70,24 @@ module WxExt
|
|
70
70
|
count: spider_posts.count
|
71
71
|
}
|
72
72
|
end
|
73
|
+
|
74
|
+
def self.spider_posts_later_date(openid, date_last = (Time.now - 3600 * 24 * 10).strftime("%Y-%m-%d"))
|
75
|
+
spider_posts_first_page_hash = spider_posts_from_sougou(openid, 1, date_last)
|
76
|
+
total_pages = spider_posts_first_page_hash[:total_pages].to_i
|
77
|
+
spider_posts = []
|
78
|
+
1.upto(total_pages).each do |page_index|
|
79
|
+
spider_posts_hash = spider_posts_from_sougou(openid, page_index, date_last)
|
80
|
+
if spider_posts_hash[:original_count] == spider_posts_hash[:count]
|
81
|
+
spider_posts += spider_posts_hash[:spider_posts]
|
82
|
+
else
|
83
|
+
break
|
84
|
+
end
|
85
|
+
end
|
86
|
+
{
|
87
|
+
total_items: spider_posts_first_page_hash[:total_items],
|
88
|
+
total_pages: total_pages,
|
89
|
+
spider_posts: spider_posts.uniq
|
90
|
+
}
|
91
|
+
end
|
73
92
|
end
|
74
93
|
end
|
data/lib/wx_ext/version.rb
CHANGED
data/lib/wx_ext.rb
CHANGED
@@ -58,21 +58,28 @@ module WxExt
|
|
58
58
|
# {"base_resp"=>{"ret"=>0, "err_msg"=>"ok"}, "redirect_url"=>"/cgi-bin/home?t=home/index&lang=zh_CN&token=1869497342"}
|
59
59
|
# {"base_resp":{"ret":-8,"err_msg":"need verify code"}}
|
60
60
|
# {"base_resp":{"ret":-23,"err_msg":"acct\/password error"}}
|
61
|
+
# {"base_resp":{"ret":-21,"err_msg":"user not exist"}}
|
61
62
|
# https://mp.weixin.qq.com/cgi-bin/verifycode?username=tuodan@thecampus.cc&r=1415774604450
|
62
63
|
res_hash = JSON.parse res.to_s
|
63
|
-
|
64
|
+
sta = res_hash['base_resp']['ret'].to_s
|
65
|
+
if sta == '0'
|
64
66
|
token_reg = /.*token=(\d+)\".*/
|
65
67
|
@token = $1 if token_reg =~ res.to_s
|
66
|
-
elsif
|
68
|
+
elsif sta == '-8'
|
67
69
|
return_hash = {
|
68
70
|
status: -8,
|
69
71
|
msg: 'need_varify_code'
|
70
72
|
}
|
71
|
-
elsif
|
73
|
+
elsif sta == '-23'
|
72
74
|
return_hash = {
|
73
75
|
status: -23,
|
74
76
|
msg: 'password_error'
|
75
77
|
}
|
78
|
+
elsif sta == '-21'
|
79
|
+
return_hash = {
|
80
|
+
status: -21,
|
81
|
+
msg: 'user_not_exist'
|
82
|
+
}
|
76
83
|
else
|
77
84
|
return_hash = {
|
78
85
|
status: -1,
|
@@ -5,7 +5,13 @@ describe WxExt::SougouWeixin do
|
|
5
5
|
|
6
6
|
it 'should spider some posts from weixin.sougou.com' do
|
7
7
|
spider_posts = WxExt::SougouWeixin.spider_posts_from_sougou('oIWsFt-tphuh--mRkYQI-TePFFBo', 1)
|
8
|
-
puts spider_posts
|
8
|
+
puts spider_posts[:spider_posts].count
|
9
9
|
expect(spider_posts[:original_count]).to eql(10)
|
10
10
|
end
|
11
|
+
|
12
|
+
it 'should spider some posts later time' do
|
13
|
+
spider_posts = WxExt::SougouWeixin.spider_posts_later_date('oIWsFt-tphuh--mRkYQI-TePFFBo', '2014-01-01')
|
14
|
+
puts spider_posts[:spider_posts].count
|
15
|
+
expect(spider_posts[:total_pages].to_s).to match(/\d+/)
|
16
|
+
end
|
11
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wx_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- flowerwrong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|