Recent Posts by crasch

Subscribe to Recent Posts by crasch 7 posts found

Jul 14, 2008
Avatar crasch 7 posts

Topic: Usage HOWTOs / Multiple constraints?

Hmmm…formatting seems a little whacked. Trying again:

Looking at the testcases, it looks like the constraints can be stacked. Here’s how I ultimately solved the problem I was working on:

sample code

Note the symbols_table extractor has two constraints: ensure_presence_of_pattern(‘price’) and select_indices(:all_but_last). I don’t know how deep you can stack the constraints, or if certain constraints can’t be stacked on each other, but the above worked for me.

Chris

 
Jul 14, 2008
Avatar crasch 7 posts

Topic: Usage HOWTOs / Multiple constraints?

Looking at the testcases, it looks like the constraints can be stacked. Here’s how I ultimately solved the problem I was working on:

def get_prices_all_funds() # Get a list of all the symbols (and their prices) in all the funds symbol_data = Scrubyt::Extractor.define do fetch ‘https://www.website.com’ fill_textfield ‘loginID’, ‘username’ fill_textfield ‘password’, ‘password’ submit click_link ‘Model Funds’ click_link ‘Model Fund #1’ click_link ‘View Holdings’ select_option(‘query.key’,’key’) submit(‘view_portal’,’GO’) symbols_table ”//table[@width=’100%’]” do symbol_row ”//tr” do end

symbol "//td[1]" do
            end.ensure_absence_of_attribute('class' => 'ftTxt10')
end
return symbol_data
shares "//td[3]" do
        end.ensure_absence_of_attribute('class' => 'ftTxt10')
end
price "//td[4]" do
    end.ensure_absence_of_attribute('class' => 'ftTxt10')
total_value "//td[5]" do
end.ensure_absence_of_attribute('class' => 'ftTxt10')
end.ensure_presence_of_pattern('price').select_indices(:all_but_last)

Note the symbols_table extractor has two constraints: ensure_presence_of_pattern(‘price’) and select_indices(:all_but_last). I don’t know how deep you can stack the constraints, or if certain constraints can’t be stacked on each other, but the above worked for me.

Chris

 
Jul 14, 2008
Avatar crasch 7 posts

Topic: Problems, Suggestions, Bugs and Other Insects / to_csv missing?

Thanks! Yeah, I went looking for the to_csv function in the code, and it looks like the entire result_dumper.rb file (where to_csv was defined) is no longer used.

 
Jul 14, 2008
Avatar crasch 7 posts

Topic: Problems, Suggestions, Bugs and Other Insects / RubyInline version conflict

Awesome. Thanks, Peter!

 
Jul 14, 2008
Avatar crasch 7 posts

Topic: Problems, Suggestions, Bugs and Other Insects / RubyInline version conflict

Hi Peter,

Did Scrubyt 0.4.0 ever get released? I’m running into a version conflict with RubyInline. Scrubyt 0.3.4 requires RubyInline = 3.6.3, but another gem requires RubyInline >= 3.6.6, so I just can’t uninstall the old version of RubyInline. Any suggestions? Is the dependency on exactly 3.6.3 real? Is there some way I can tell scrubyt just to use the older version (which is still installed)?

Heres the specific error I’m getting:

/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:142:in `activate’: can’t activate RubyInline (= 3.6.3, runtime), already activated RubyInline-3.7.0 (Gem::Exception) from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:158:in `activate’ from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `each’ from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `activate’ from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’ from ./folioScrape.rb:13

Thanks!

 
Jul 14, 2008
Avatar crasch 7 posts

Topic: Problems, Suggestions, Bugs and Other Insects / to_csv missing?

I have the following version of scrubyt installed

scrubyt (0.3.4) A powerful Web-scraping framework built on Mechanize and Hpricot

Since I believe the to_csv function was added in 0.2.8, I assume it should be there.

Writing to_xml works:

symbol_data.to_xml.write($stdout,1)

But writing to_csv does not:

symbol_data.to_csv.write($stdout,1)

When I try to execute the above, I get:

/usr/local/lib/ruby/gems/1.8/gems/RubyInlineAcceleration-0.0.1/lib/inline_acceleration.rb:101:in `method_missing’: undefined method `to_csv’ for #<scrubyt::scrubytresult:0x28c96bc> (NoMethodError) from ./folioCheck.rb:161:in `get_prices_all_funds’ from ./folioCheck.rb:172

Any suggestions? Thanks!

Chris

 
Jul 3, 2008
Avatar crasch 7 posts

Topic: Usage HOWTOs / Multiple constraints?

I get how to do one constraint:

symbol_list "/html/body/tr/td/table/tr" do
    symbol "/td[1]/a[1]/span[1]" 
    last_price "/td[4]" 
end.ensure_presence_of_pattern 'symbol'

But what if I wanted to constrain on both symbol and price?

Thanks!

Chris