Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How do I know if the response for a url is 200 or 404 and how do I check the availability of the url?
You can make a GET request using Net::HTTP:
uri = URI('http://example.com/index.html')
res = Net::HTTP.get_response(uri)
puts res.code
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have simple HTML form, which I got from a web page:
<form id="my">
inputs....
</form>
I need to get this form via it's ID, which I know how to do:
#get_doc = Nokogiri::HTML(page)
nb = #get_doc.at_css('#my')
maybe could i iterate via object ?
I need to get all the input values and input names into some variable, and then pass it to URI.encode_www_form.
How can I do this? How could I get all the inputs inside the form with names and values, and pass them to encode_www_form?
arr = []
# form = doc.at_css '#form'
form.css('input').each do |i|
arr << [i['name'], i['value']]
end
URI.encode_www_form arr
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Here is ruby code:
[:val1, :val2, :val3].each do |method_name|
define_method(met_n) do |param1, param2|
inflect(param1, param2, SOME_CONST[met_n.to_s])
end
end
It's not mine code. I tried to figure out what inflect is, but I failed, although it should be a standard ruby function.
So how is it defined or where do I find a documentation about it?
inflect isn't a standard ruby function. This must be part of someone else's API.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I load an OWL file in Gruff? It's not clear in the tutorials. I have a file, camera.owl. I need to display this in Gruff and view a graph of it.
I found the answer to this question myself. You need to look under the file menu. File > Load Triples > RDF/XML > File .... Thank you.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I rewrite this Java statement in Ruby?
for (Map.Entry<byte[], HServerLoad.RegionLoad> entry : serverLoad.getRegionsLoad().entrySet()){
}
Thanks for your help!
If you want to iterate a ruby map(hash) with key and values you could write
h.each { |k, v| puts "Key=#{k}, Value=#{v}" }
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to download all the links in a webpage using a ruby script. My idea was to extract the href links if I could get the Source code, set a download location using command prompt. Is there a way for this ?
#!/usr/bin/env ruby
#
require "net/http"
require "uri"
#past your link
gets = STDIN.gets rescue nil
url = URI.parse gets
http = Net::HTTP.start(url.host, url.port) do |resp|
puts resp.get(url.request_uri).body
end
#your regular for href
or use http://nokogiri.org/