Sha256: da95bd917758badfde127bc035142db2d52cc3772236a1abe8c6f08a7968ba9f
Contents?: true
Size: 597 Bytes
Versions: 16
Compression:
Stored size: 597 Bytes
Contents
require 'httpclient' require 'json' require 'nokogiri' require 'open-uri' def request_json_parse(url) client=HTTPClient.new() response=client.get(url) if response.status==200 return JSON.parse(response.body),response.status end return nil,response.status end def request_html_parse(url,opt) charset=nil status=[] response=URI.open(url,opt) do |f| charset=f.charset status=f.status f.read end if status[0]=="200" return Nokogiri::HTML.parse(response,nil,charset),status end return nil,status end
Version data entries
16 entries across 16 versions & 1 rubygems