पार्सिंग HttpResponse साथ HttpResponse पार्स करने, मैं कर रहा हूँ मुसीबत पार्स करने HttpResponse Nokogiri के साथ वस्तुओं।रूबी Nokogiri</p> <p>हाय के साथ Nokogiri
मैं इस सुविधा का उपयोग एक वेबसाइट यहाँ लाने के लिए:
एक लिंक
def fetch(uri_str, limit = 10)
# You should choose better exception.
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
url = URI.parse(URI.encode(uri_str.strip))
puts url
#get path
req = Net::HTTP::Get.new(url.path,headers)
#start TCP/IP
response = Net::HTTP.start(url.host,url.port) { |http|
http.request(req)
}
case response
when Net::HTTPSuccess
then #print final redirect to a file
puts "this is location" + uri_str
puts "this is the host #{url.host}"
puts "this is the path #{url.path}"
return response
# if you get a 302 response
when Net::HTTPRedirection
then
puts "this is redirect" + response['location']
return fetch(response['location'],aFile, limit - 1)
else
response.error!
end
end
html = fetch("http://www.somewebsite.com/hahaha/")
puts html
noko = Nokogiri::HTML(html)
लाने जब मैं इस एचटीएमएल प्रिंट करना निरर्थक शब्दों की एक पूरी गुच्छा और Nokogiri शिकायत है कि "node_set एक Nokogiri होना चाहिए :: एक्सएमएल :: nodeset
किसी को भी मदद की पेशकश कर सकता है यह काफी सराहना की जाएगी
आप इस गर्म गंदगी के बजाय मशीनीकरण उपयोग करना चाहिए। यह आपके लिए एन्कोडिंग के साथ रीडायरेक्ट और सौदों का ख्याल रखता है। – pguardiario