Forum: Ruby URL Content in Variable

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A4162c8ddcdc932001aca326b1f3eeca?d=identicon&s=25 Max Lurch (audio007)
on 2017-03-15 13:55
Hello,
i want ruby to take the Content from a Website an write this in a
variable.
Can somebody help me?
Greetz
0026dd77fd9ecc97b36e5b79cdbcf590?d=identicon&s=25 R. Kumar (sentinel)
on 2017-03-15 14:58
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/retriev...

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/...

If it's a website, you probably want to use the nokogiri gem to parse
the content and get exactly what you want.
A4162c8ddcdc932001aca326b1f3eeca?d=identicon&s=25 Max Lurch (audio007)
on 2017-03-15 15:28
Is where any way to do this with a Website which is opend by an android
device?
D745045cb64c1b79937cc016a2dbf937?d=identicon&s=25 Danny Samuel (dannysamuel)
on 2017-04-18 07:22
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/
This topic is locked and can not be replied to.