For Loops and open-uri

S

Scott B.

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:

<URL>/player/1*

* 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 = <URL>/player/<Increment>

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.

Scott.
 
S

Scott B.

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.

Scott.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top