OpenURI is a Ruby module included in the standard library, which provides an easy-to-use wrapper for net/http, net/https and net/ftp.
Questions tagged [open-uri]
311 questions
0
votes
1 answer
Running rake task with open-uri on Heroku results in Connection Refused error
I wrote a rake task that populates my database with data from a third-party API.
namespace :populate do
desc "Populate database with data from first page of TicketWeb API"
task :one_page => :environment do
require 'open-uri'
json_data =…

Pance
- 101
- 2
0
votes
1 answer
Ruby EOFError with open-uri and loop
I'm attempting to build a web crawler and ran into a bit of a snag. Basically what I'm doing is extracting the links from a web page and pushing each link to a queue. Whenever the Ruby interpreter hits this section of code:
links.each do |link|
…

nizbit
- 43
- 7
0
votes
2 answers
How do I add an extension to a file when downloading it?
This magical Ruby script downloads a couple of XML files from a website, but the files don't have an extension. I'd like to add the prefix .xml to every file it downloads.
This is where I am right now and it won't work:
require 'rubygems'
require…
user592638
-1
votes
1 answer
Is there an update to open-uri that changes the way you call a User-Agent?
In the book "Instant Nokogiri" and on the Packt Hub Nokogiri page it has a User-Agent application for spoofing a browser while crawling the New York Times website for the top story.
I am working through this book but the code is a little dated, but…

MetaG
- 39
- 10
-1
votes
2 answers
What is variable p in open uri module in ruby?
I am currently trying to parse a file in ruby and I ran into this example in the open uri module documentation (http://ruby-doc.org/stdlib-1.9.3/libdoc/open-uri/rdoc/OpenURI.html):
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p…

user2129856
- 31
- 1
- 6
-1
votes
1 answer
Turn a static request into ajax using a ruby gem?
I have a very basic app which hooks into the (http://is.gd) API, shortening any user-specified URL. Here's the current code I have to do this (works perfect as a static request):
# app.rb
require "sinatra"
require "open-uri"
def shorten_url(url)
…

Adam McArthur
- 950
- 1
- 13
- 27
-1
votes
2 answers
Regexp for finding href in open-uri ruby
I need to find distance between two websites useing ruby open-uri. Using
def check(url)
site = open(url.base_url)
link = %r{^<([a])([^"]+)*([^>]+)*(?:>(.*)<\/\1>|\s+\/>)$}
site.each_line {|line| puts $&,$1,$2,$3,$4 if (line=~link)}
…

Torianin
- 171
- 2
- 9
-2
votes
1 answer
How to check if a JPEG is readable
Is it possible to check that a picture that I downloaded is readable, if a picture viewer is going to tell me it cannot open it for some reason.
Example:
"invalid byte sequence in conversion input" when mousepad is used because Ephoto could not open…

Matthieu Raynaud de Fitte
- 2,001
- 3
- 25
- 49
-2
votes
1 answer
How to pass to CSV file only the first five tracks?
require "openssl"
require "nokogiri"
require 'csv'
require "open-uri"
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
$n=0
#~ Open_Page
page = ('http://www.residentadvisor.net/dj/aguycalledgerald/tracks?sort=mostcharted')
html =…

Leo F
- 17
- 1
- 2
-2
votes
2 answers
Ruby - nokogiri, open-uri - Fail to parse page
This code work on some pages, like klix.ba, but cant figure out why it doesn't work for others.
There is no error to explain what went wrong, nothing.
If puts page works, which means I can target the page, and parse it, why I cant get single…

Nemilenko
- 353
- 2
- 3
- 9
-3
votes
1 answer
How do I automate Nokogiri?
While learning how to use Nokogiri in Ruby,I got this idea,what if I can automate these commands which I write in bash for Nokogiri?
Is there any way or method which I can use to automate the call?
For example: As I was trying to grab some data from…

Abhinay
- 1,796
- 4
- 28
- 52