I keep learning new things. This time advanced web scraping with NightmareJS but soon I faced this issue. Let’s see how to fix
$ is not defined on NightmareJS.
$ is not defined on NightmareJS
The cause is the jQuery file is not included in your script. You need to add this:
Please note you must have the jQuery file at the same level as the script and the filename should match.
Try and it should work!
var nightmareScript = new Nightmare() .goto('https://www.google.com') .inject('js', 'jquery.min.js') // Look here! .wait();
Then you can evaluate the page and the DOM with jQuery. Happy scraping!
Feel free to leave your doubt or comment 🙂