- Install PhantomJS
- Run the PhantomJS Hello, World code to make sure everything's working; you can also start a PhantomJS console by running
phantomjs
and entering the quickstart commands manually - Install CasperJS
- Run the CasperJS Google Scraping example
-
Modify Phantom's follow.js example to display the Twitter followers from the @bmorejs and your own account (if any).
-
Observe the amount of control you have over the browser, but then see how cumbersome writing code like this would be for a more complex scraping application.
-
Run Casper's googlelinks.js example with your own search terms (like your name).
-
Rewrite the
follow.js
code to run with Casper. There's a sample answer in thejs/solutions
directory of this project. No peeking unless you're stuck! -
Modify
googlelinks.js
orfollow.js
to take a screenshot of the results page and save as apng
file using Casper's capture method.
-
Write a basic site availability tester for one of your current projects using Casper's Tester module. Check out this example for inspiration. You can run
echo $?
after Casper finishes to see an exit code (0 if the tests all pass; otherwise 1); -
There's also a solution for this exercise in
js/solutions
; again, no peeking!
-
Install the Casper
__utils__
bookmarklet from here and try experimenting with__utils__
helpers, especiallygetElementByXpath
andmouseEvent
. -
Try using PhantomJS as a websniffer to measure the perform of one of your current web projects, as demonstrated by Ilya Grigorik.
-
Write a CasperJS version of this Mechanize webscraper.
-
If you are a Ruby dev, check out Poltergeist which lets you write Ruby code to drive PhantomJS.