Reputation: 1
I've written some code that loops through this results table and prints the href of every entry. The loop works fine until it hits the tr 26. Does anyone have any idea why? This is what my code looks like right now:
require 'rubygems'
require 'mechanize'
require 'nokogiri'
require 'open-uri'
#Setup
listings_page = Nokogiri::HTML(open('http://servico-informatica.vivanuncios.com/computador+rio-de-janeiro-capital/'))
listings_page.css( "#classified_table tr.classified").each do |listing|
puts listing.css(".summary .classified-link")[0]["href"]
end
I checked the CSS and it doesn't seem like anything changes markup wise among the TRs. I'm aware there are different types of TRs (classified vs advertisement) but that's fine since I don't want to extract the ads.
Upvotes: 0
Views: 201
Reputation: 126772
The document at that URL has only a single table
element with an id
of classified_table
.
That table has just one tr
element (with no class
attribute) of two columns. The first element is another table with 39 tr
elements. 35 of them have a class
that includes classified
, while the other four have a class of vs-advertisement
.
You are getting the correct result.
Upvotes: 1