query 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/query/engine/baidu.rb +2 -2
- data/lib/query/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c95c194c67e1ea98bd3b1acda8d6d1f5820bfbe4
|
4
|
+
data.tar.gz: 295dfac6c23a431ff8c81cc5f98490d516d2bc53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c64749e7bb27d51fcc5721495f866eb39f468d2bc9d8d1f78873bfe3ab7dd227815e9843be1519d1a40ea0b90fbd6ae24980f228cbde72756831e67045f32d73
|
7
|
+
data.tar.gz: 5657fdadf58e46fed30182311bc1e18b84c95e1d2d3cc210eb24bd0cc55ffbc7ddd95319fbed3057698023f3df375e8f590b60ea37182a4225408b8100ce58a9
|
data/README.md
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
Query
|
2
2
|
==========
|
3
3
|
|
4
|
+
现在抓百度下拉框可以用代理了
|
4
5
|
|
6
|
+
```ruby
|
7
|
+
require 'query'
|
8
|
+
opt = {
|
9
|
+
http_proxyaddr: '0.0.0.0',
|
10
|
+
http_proxyport: 80
|
11
|
+
}
|
12
|
+
|
13
|
+
puts ::Query::Engine::Baidu.suggestions('abc',opt)
|
14
|
+
```
|
5
15
|
|
6
16
|
#to get the result list by querying "abc"
|
7
17
|
|
data/lib/query/engine/baidu.rb
CHANGED
@@ -8,10 +8,10 @@ module Query
|
|
8
8
|
:headers => {"User-Agent" => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11'}
|
9
9
|
}
|
10
10
|
|
11
|
-
def self.suggestions(query)
|
11
|
+
def self.suggestions(query,options = [])
|
12
12
|
require 'json'
|
13
13
|
query = URI.encode(query)
|
14
|
-
suggestions = HTTParty.get("https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=#{query}&json=1&p=3&sid=&req=2&csor=0&cb=jQuery1102036467162938788533_1437556180622&_=#{(Time.now.to_f*1000).to_i}")
|
14
|
+
suggestions = HTTParty.get("https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=#{query}&json=1&p=3&sid=&req=2&csor=0&cb=jQuery1102036467162938788533_1437556180622&_=#{(Time.now.to_f*1000).to_i}",options)
|
15
15
|
suggestions.force_encoding('GB18030').encode('UTF-8').delete('jQuery1102036467162938788533_1437556180622(').delete(')').scan(/"q": "([^"]+)"/).flatten.uniq
|
16
16
|
end
|
17
17
|
#to find out the real url for something lik 'www.baidu.com/link?url=7yoYGJqjJ4zBBpC8yDF8xDhctimd_UkfF8AVaJRPKduy2ypxVG18aRB5L6D558y3MjT_Ko0nqFgkMoS'
|
data/lib/query/version.rb
CHANGED