URL Content in Variable


#1

Hello,
i want ruby to take the Content from a Website an write this in a
variable.
Can somebody help me?
Greetz


#2

Max Lurch wrote in post #1185688:

Hello,
i want ruby to take the Content from a Website an write this in a
variable.
Can somebody help me?
Greetz

http://stackoverflow.com/questions/3193538/retrieve-contents-of-url-as-string

basically:

open(“http://www.ruby-lang.org/”) {|f|
f.each_line {|line| p line}
}

You can append the contents to a string or array within the loop.

See the docs at:
https://ruby-doc.org/stdlib-2.1.0/libdoc/open-uri/rdoc/OpenURI.html

If it’s a website, you probably want to use the nokogiri gem to parse
the content and get exactly what you want.


#3

Is where any way to do this with a Website which is opend by an android
device?


#4

dynamically building my Manifest file for Application Caching in MVC4. I
know it’s on the way out (or appears to be) but I do still need to
support older browsers.
The site is in MVC, but we do have a couple ASPX pages because we need
to use some legacy controls. So in my manifest file I am trying to
create a relative path to the ASPX pages using Url.Content(), which
seems to work until I need to add a couple parameters and the “&” is
encoded. Without the “&” it seems to work (except that it loads/caches
the wrong thing).

And since it’s a manifest file, I cannot do a redirect, as any redirect
causes the application cache to fail.Even though it’s MVC4, I cannot
just start with the “~” because it doesn’t get parsed as it would in an
image or anchor.
http://essaysthatwins.com/


#6

This post was flagged by the community and is temporarily hidden.