Sha256: 4cb2be8f4845d4d78e12e43af9988a083165c2abf35cb9c579d5899024e5609b

Contents?: true

Size: 785 Bytes

Versions: 40

Compression:

Stored size: 785 Bytes

Contents

module HttpCrawler
  module Web
    module Baidu
      class Client < HttpCrawler::Web::Client

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

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

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

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

      end
    end # module Baidu
  end # module Web
end # module HttpCrawler

load File.dirname(__FILE__) + '/response/index.rb'

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
http_crawler-0.3.2.3 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.2.2 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.2.1 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.2.0 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.31 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.30 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.29 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.28 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.27 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.26 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.25 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.24 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.23 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.22 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.21 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.20 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.19 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.18 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.17 lib/http_crawler/web/baidu/client.rb
http_crawler-0.3.1.16 lib/http_crawler/web/baidu/client.rb