Sha256: bf95b2c028777d6a42e7649b09e54e62fa126cfe4fe628f52a11087555bac050
Contents?: true
Size: 753 Bytes
Versions: 5
Compression:
Stored size: 753 Bytes
Contents
require 'digger' require 'json' require 'uri' require 'cgi' describe Digger::Page do it 'page json' do json_str = '{"a":1,"b":[1,2,3]}' j1 = Digger::Page.new('', body: json_str) j2 = Digger::Page.new('', body: "hello(#{json_str});") expect(j1.json['a']).to eq(1) expect(j2.jsonp['a']).to eq(1) expect(j1.json['b'][0]).to eq(1) expect(j2.jsonp['b'][1]).to eq(2) end it 'fetch baidu' do http = Digger::HTTP.new page = http.fetch_page('http://baidu.com/') expect(page.code).to eq(200) end # it 'page uri' do # link = 'https://www.baidu.com/s?wd=%E5%93%88%E5%93%88#hello' # link = link.to_s.encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/#\w*$/, '') # end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
digger-0.2.2 | spec/page_spec.rb |
digger-0.2.1 | spec/page_spec.rb |
digger-0.2.0 | spec/page_spec.rb |
digger-0.1.9 | spec/page_spec.rb |
digger-0.1.8 | spec/page_spec.rb |