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