[Note: parts of this message were removed to make it a legal post.]
What you can do is write three loops so
[A..Z].each do |letter|
[1...num].each do |number|
#Process the website in here
process_website letter number
end
end
As for OOP you could have a Parse class and in and a AppRunner class (which
holds all the websites). the process_website would be in the AppRunner class
and would create a new parser for each website, parse the website and then
either if the websites are indepent (have the parse take care of the writing
to csv), or if dependent in some manner (have the AppRunner write to cvs)
Reuben Doetsch
On Thu, Jul 17, 2008 at 9:47 AM, Li Chen <> wrote:
> Hi all,
>
> I try to write a script to fecth some webpages from the internet, parse
> the webpages and write them into csv format file.
>
> Here are the formats of webpages:
> website....A001
> ...
> website....A101
>
> website....B001
> ...
> website....B401
>
> website....Z001
> ...
> website....Z301
>
> I use two loops to do the job. 1) one loop is to iterate from letter A
> to Z,
> which I have it done by iterate an array containing letter A to Z.
> 2) another loop is to iterate the number from 1 to whatever numbers I
> prefer (or using a while loop).
>
> If I write the script in a procedural way I have no problem at all but
> they look kind of ugly. Now I try to rewrite them with OOP method. My
> confusion here is that where should I write the loops: in the main
> scripts and define a method for them and call the method in the main
> scripts?
>
> Thanks,
>
> Li
> --
> Posted via http://www.ruby-forum.com/.
>
>