Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:42:19+00:00 2026-06-11T08:42:19+00:00

I have the following ruby script: require rubygems require rest-client #although not required in

  • 0

I have the following ruby script:

require "rubygems"
require "rest-client" #although not required in the program
require "open-uri"
require "nokogiri"


puts "Opening file"
page=File.open("file.html","r"){|file| file.read}
puts page
    page = Nokogiri::HTML(page)
    puts page.class
    #Filters content of page to select all references to the documents filing date
    td_rows = page.css('td i.blue')
    puts td_rows

I can run this script from CodeRunner or TextWrangler and invoke it from the terminal using ruby ‘filename’. However, I am trying to get the script to run at a certain point in time and have tried calling the script using Keyboard Maestro or Platypus but although it runs it does not seem to complete the line

td_rows = page.css('td i.blue')

The variable td_rows contains nothing. Does anyone have any idea why this will not work?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:42:20+00:00Added an answer on June 11, 2026 at 8:42 am

    I managed to find out why the nokogiri parse was not working.

    For some reason, if the page was opened from the web, the script would work but if the web page was saved to disk first and then opened it did not. I found that when the page was opened from disk it encountered a nokogiri error and only read and parsed the first few lines of the file. The error was due to a html comment not being closed on the same line but on a subsequent line.

    I managed to overcome this problem by reading the file with the mode “rb” instead of just “r”. i.e. if I replace the file.open line with:

    page=File.open("file.html","rb"){|file| file.read}
    

    nokogiri correctly parses the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Ruby script: require 'nokogiri' require 'erb' listing = %Q{<% listing
I have the following script: #!/usr/bin/env ruby require 'rubygems' require 'net/ssh' Net::SSH.start('host1', 'root', :password
I have the following test Ruby script: require 'tempfile' tempfile = Tempfile.new 'test' $stderr.reopen
This is not a ruby/rails project deploy. I have the following situation and I
I have the simple following code, which is working in a ruby (not rails)
I have the following Ruby script that creates a Debian package, which works fine:
I have the following Ruby script, in which class Foo includes module Baz, module
I have implemented Ruby C extension(i.e. Invoking C function from ruby script) Following is
I have the following function in ruby for retrieving certain information from a database.
If I have the following piece of Ruby code: class Blah def self.bleh @blih

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.