I needed to do some screen scrapping using Ruby, so after a few google searches I came across this
post which looked very promising, after a quick scan through the comments
scRUBYt looked even better.
stumbling block #1: well it did take me a bit to get it installed, turns out it is currently (0.3.4) hard-wired to use RubyInline 3.6.3, but I had RubyInLine 3.7.0 installed, this
post gives the details to work around this issue, otherwise you will get an error something like
Gem::Exception: can’t activate RubyInline (= 3.6.3), already activated RubyInline-3.7.0].
stumbling block #2: trying the simple example for scrapping google
here I got the following error -
can’t convert Hash into String. So I tried commenting out some of the code, just limiting it to hit the submit button, the result - no error but no output either? after looking around on the
scRUBYt forums turns out scRUBYt logging is not on by default, so turn it on…
Scrubyt.logger = Scrubyt::Logger.new and run the code again
[ERROR] No extractor defined, exiting… ok, so un-comment the code and run it again now that I have the logging on, same error, I am obviously doing something wrong? try a couple other code samples, more fun error messages -
The error occurred while evaluating nil.example_type.
Well it turns out I was jumping ahead because I was calling this code from inside a
Rake task. After moving the code into a regular ruby file and calling it using ruby instead of rake everything works just great! I did not look into why this code is failing from inside the rake task but I am guessing there is some conflict with the libraries? an exercise for another day…