Reputation: 103
I am trying to scrape data using Nokogiri. The code I am trying to access is:
<div class="main-header">
<span>Make More Money</span>
</div>
I want to get the text "Make More Money", only. Here is my code:
url = 'xyz.com'
doc = Nokogiri::HTML(open(url))
doc.at_css('main-header span').text
Using this I am getting a NilClass
error. What do I need to do to fix this?
Upvotes: 0
Views: 191
Reputation: 24350
The .
for the class main-header
is missing. It should be
doc.at_css('.main-header span').text
Upvotes: 4