Wondering if there is a way to have variable webpage?

0 views
Skip to first unread message

A Y

unread,
Jan 8, 2012, 11:55:26 PM1/8/12
to nokogiri-talk
I'm fairly new to Nokogiri so please bare with me. I'm writing a
little script to grab sports from a website. I would like to have the
option of being able to pick which day's games (i.e. previous,
current, next, etc.,). I was wondering if there's a way that I would
be able to use Nokogiri to parse through the base page (current days
scores) then use it to grab the link to the page with the previous
day's scores and redefine the page it's using? (or the next days) I
don't want to have to hardcode it into the program if I really don't
have to.

Walter Lee Davis

unread,
Jan 9, 2012, 12:29:21 PM1/9/12
to nokogi...@googlegroups.com
That's going to depend a lot on the page you're reading. If the author of that page has used some consistent method to mark the next and previous page links (a classname, the text content of the link) then Nokogiri offers you strong tools to dig that out.

previous = doc.css('a.previous')
if previous.length > 0
previous_page = previous.first()
#do something with previous_page['href']
end

Walter

> --
> You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
> To post to this group, send email to nokogi...@googlegroups.com.
> To unsubscribe from this group, send email to nokogiri-tal...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nokogiri-talk?hl=en.
>

Reply all
Reply to author
Forward
0 new messages