selectively applying extractor patterns
I am searching for a particular company in a search results page that has many companies listed. Now, if the company I am looking for is found, then I want to write the extracted company details to a file and exit. If it is not found, I want it to apply an extractor pattern to find the 'NextPage' hyperlink, and if found, follow that link and search in that page again.
Now when the company is available in page 1, I have no problem. But, if the company is not found there, how do I
1. invoke the NextPage extractor pattern from a script?
2. prevent the NextPage extractor pattern from executing automatically under both conditions, as sequence of that pattern is by default 2?
Thanks in advance.
If you want a better picture, this is the URL I'm scraping:
http://www.nasdaq.com/asp/symbols.asp?exchange=Q&start=I&page=1&sort=nam...
Now, say I'm looking for a company called infosys, it works fine because it is available on the page 1.
If I want to search for a company called Intel, which is on page 2, how should I write my script and extractor patterns?
solution using a different approach
I found a solution to the problem. I eliminated the extractor pattern for next link and implemented it as follows:
I used a flag to indicate whether the company name i'm searching for was found on that page or not. This gets set the moment i find the right name.
So, at the end of the loop, after examining all company names on a page, if the flag shows I haven't found it yet, I increment and set variables like Page number and scrape the file again.
I would still like to know if there is a solution to my previous query.
Thank you.