Class: HttpCrawler::Web::Baidu::Client

Inherits:
Client show all
Defined in:
lib/http_crawler/web/baidu/client.rb

Instance Method Summary collapse

Instance Method Details

#index(parameter = {}) ⇒ Object



16
17
18
19
# File 'lib/http_crawler/web/baidu/client.rb', line 16

def index(parameter = {})
  r = get("/")
  r.extend(HttpCrawler::Web::Baidu::Response::Index)
end

#init_client ⇒ Object



7
8
9
10
# File 'lib/http_crawler/web/baidu/client.rb', line 7

def init_client
  # 设置整体超时时间 3 秒
  @all_timeout = 3
end

#init_uri ⇒ Object



12
13
14
# File 'lib/http_crawler/web/baidu/client.rb', line 12

def init_uri
  @uri = URI("https://www.baidu.com")
end

#search(parameter = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/http_crawler/web/baidu/client.rb', line 21

def search(parameter = {})
  raise "parameter[:keyword] 不能为空" unless parameter[:keyword]
  params = {
      "wd": parameter[:keyword]
  }
  r = get("/s",params)
  r
end