Skip to content
Advertisement

In Symfony/Panther when scraping, waitfor function will throw exception if it timesout – i need it to continue if item is not found

I have a database of clinics, and an url to each clinic. All clinic pages are the same in terms of html/css, with different content to scrape.

However, some clinics have no content on their page, and this causes trouble for me.

I have:

JavaScript

If .facility is not present, the waitFor() will throw exception because of timeout. I need to be able to continue in that case, and not throw an exception. So if it times out, it should continue and not end.

I cannot count the facility items and check it that way, since these are loaded with ajax and are not present at the start of page load.

What I have tried and researched:

Is it possible for symfony/panther to wait for some elements n times?

HowTo Wait – PHPWebDriver

Advertisement

Answer

You could just catch the exception, like this…

JavaScript

At the top of your class you may need to add (That’s what the code looks like it is using.):

JavaScript

Also note that the function has other parameters that could be useful:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement