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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d2286ab5475583239a332f578ae2f43054ba264
4
- data.tar.gz: 333b03607b64a19cbbb7a8aceac273e7c721533c
3
+ metadata.gz: 9bc728f6d9fa05657b9ea77a14be415b1da612e9
4
+ data.tar.gz: 3c78fc17004bb1f828c9bae82faf59e989a3d635
5
5
  SHA512:
6
- metadata.gz: 4179d378f97c60d3eee82dfbf8c1016123b15207bf07b80dade2bba36606a4e6f954307b4a6153e108ea0512a17fc38f8ea896890c6d49a37c3a6940c44d5131
7
- data.tar.gz: 379d657c157449af7db4efd494fc3b074f2072077d2074c8000d7b178bfe387d6a3c9dc78f65b60218bbb769046c1aa2f2a5f292d96e1e81a5bc6b12f96acd27
6
+ metadata.gz: a9cae7ea78c641aadab551b1399ac880d994d941dcb0ffbc125e976614340d7036a5c6272cd1c571677fbc692b1d78ef6dfb42eeb1fe712c42baf55b7b78a548
7
+ data.tar.gz: 0b9e47830b57aa31733e98915c9ea1d7ff4e1953b578229a6112cbcb647493841f892a810313f24ed5904905f7f0a714e858e4e6946265b92b58170dc25adb21
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'wx_ext', '~> 0.1.2'
10
+ gem 'wx_ext', '~> 0.1.3'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -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
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module WxExt
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
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
- if res_hash['base_resp']['ret'].to_s == '0'
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 res_hash['bash_resp']['ret'].to_s == '-8'
68
+ elsif sta == '-8'
67
69
  return_hash = {
68
70
  status: -8,
69
71
  msg: 'need_varify_code'
70
72
  }
71
- elsif res_hash['bash_resp']['ret'].to_s == '-23'
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.2
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-09 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler