These are chat archives for rosshinkley/nightmare

9th
May 2017
Amrutha Ramesh
@amrutharamesh
May 09 2017 01:56
Hey all, i have been scraping with nightmarejs for sometime now. I am trying to scrape stuff that is inside a modal popup that only opens on click of the element. But I have designed my scraper in a way that it only extracts a href of the element and navigates to that page and does its work instead of clicking. i did this because for click i need to pass a selector which I don know beforehand for every site i am scraping. and extracting it from a page and then clicking the element hasnt always proved reliable for me. But the problem is there are pages that dont have an alternate href for the popup i want to access and only open it on click of the button. Now having designed my whole scraper to extract href, can i incorporate click in the same process (when the href fails) or do i have to do a separate set of tasks for this purpose?
since nightmarejs is set of tasks that are done in steps how can i also incorporate an alternate action after the initial evaluate is not successful?
Davide De Gennaro
@dege88
May 09 2017 10:06
@amrutharamesh you can add the conditional code in an evaluate call and inject a javascript snippet that check for the link or clicks the button
johnferro
@johnferro
May 09 2017 14:05
@amrutharamesh Alternatively you can take the result of whatever gets the href and use that to branch the promise/whatever async flow you're using