Last active
August 17, 2018 15:22
-
-
Save hnaohiro/9811379 to your computer and use it in GitHub Desktop.
Scrape Facebook with CasperJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
casper = require('casper').create() | |
casper.start "https://facebook.com", -> | |
query = | |
email: 'youremail' | |
pass: 'yourpass' | |
@fill "#login_form", query, true | |
casper.thenOpen 'https://facebook.com/username' | |
casper.then -> | |
tryAndScroll = -> | |
casper.waitFor -> | |
casper.scrollToBottom() | |
true | |
, -> | |
unless casper.visible '.createdAccountUnit' | |
tryAndScroll() | |
tryAndScroll() | |
casper.then -> | |
elements = JSON.stringify @getElementsInfo('.userContent') | |
require('fs').write('user_content.json', elements) | |
casper.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting a "Cookies not enabled" error (from the Facebook screenshot) at login. Any idea how to work around this?