Getting webpage content with Ruby — I'm having troubles

后端 未结 3 1263
一生所求
一生所求 2020-12-14 21:53

I want to get the content off this* page. Everything I\'ve looked up gives the solution of parsing CSS elements; but, that page has none.

Here\'s the only code that

3条回答
  •  情话喂你
    2020-12-14 22:54

    Please use open-uri, its support both uri and local files

    require 'open-uri'
    contents  = open('http://www.google.com') {|f| f.read }
    

提交回复
热议问题