sparklemotion / mechanize

Mechanize is a ruby library that makes automated web interaction easy.
https://www.rubydoc.info/gems/mechanize/
MIT License
4.39k stars 473 forks source link

wikipedia_links_to_philosophy.rb currently broken #604

Closed palladius closed 1 year ago

palladius commented 1 year ago

Hi, I don't know if the wikipedia schema changed or whrat, but I get this error (all other RB example files I've tried work perfectly - you're AMAZING! Inspired me so much!)

$ ruby wikipedia_links_to_philosophy.rb 
Wa'el Nassar
/Users/ricc/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mechanize-2.8.5/lib/mechanize/page/link.rb:24:in `initialize': undefined method `[]' for nil:NilClass (NoMethodError)

    @href       = node['href']
                      ^^^^^^^^
        from wikipedia_links_to_philosophy.rb:85:in `new'
        from wikipedia_links_to_philosophy.rb:85:in `follow_first_link'
        from wikipedia_links_to_philosophy.rb:143:in `run'
        from wikipedia_links_to_philosophy.rb:159:in `<main>'

$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

mechanize version: -2.8.5 ruby version

flavorjones commented 1 year ago

Thanks for reporting it, I'll take a look!

flavorjones commented 1 year ago

Yes, the wikipedia page layout has changed over time. I'll update the script.

flavorjones commented 1 year ago

Fixed in 84ca53e0