For Loops and open-uri

Hi guys,

I’m a newbie to Ruby and having some problems trying to work out how to
tackle a for loop problem.

Basically, I have a website I’m trying to scrape (fantasy football
stats, nothing commerical) in order to enter into a sqlite database.
There is a webpage per player that starts with a 1 and then increments
so basically:


  • This number will increment up to approximately 700

What I am trying to do is have a for loop first determine whether the
page exists (i’m guessing is not a 404), then scrape stats from that
page then move onto the next URL (which would be an increment). So:

for (exists)
scrape data
enter into database
url = /player/

I wanted to learn Ruby/Rails in a different way rather than tutorials of
a twitter clone but am having issues with the logic of this problem.
Anyone have any ideas?
Thank you in advance.


I got it guys. Turns out, the error page does not throw a 404, it just
displays a normal formatted page with junk data. Was able to use that to
devise the for look.
Thanks anyway.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs