Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError when fetching encoding type from a particular document #655

Closed
boncey opened this issue Apr 13, 2012 · 4 comments
Closed

NoMethodError when fetching encoding type from a particular document #655

boncey opened this issue Apr 13, 2012 · 4 comments

Comments

@boncey
Copy link

boncey commented Apr 13, 2012

When trying to fetch the encoding type from http://www.ropetacklecentre.co.uk/ I get the following error:

doc = Nokogiri::HTML(open('http://www.ropetacklecentre.co.uk/'))
>> doc.meta_encoding
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
from /Users/boncey/.rvm/gems/ruby-1.8.7-p358/gems/nokogiri-1.5.2/lib/nokogiri/html/document.rb:9:in `meta_encoding'
from (irb):7
from :0

The HTML source is at https://gist.github.com/2379007

It looks like their <meta http-equiv="Content-type" content="text/html; utf-8" /> is a bit dodgy.

Thanks, Darren.

@maxwellE
Copy link

do you have

require 'open-uri'

before that Html Open?

@boncey
Copy link
Author

boncey commented Apr 19, 2012

Yes I do.

I'm using this same code to successfully fetch the encoding from hundreds of documents.
Only this page fails.

@flavorjones
Copy link
Member

Fix will be in 1.5.3. I'll publish an RC soon.

@boncey
Copy link
Author

boncey commented Apr 26, 2012

Brilliant, thanks for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants