Skip to content

Instantly share code, notes, and snippets.

@hnaohiro
Last active August 17, 2018 15:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hnaohiro/9811379 to your computer and use it in GitHub Desktop.
Save hnaohiro/9811379 to your computer and use it in GitHub Desktop.
Scrape Facebook with CasperJS
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()
@Spoonrad
Copy link

I'm getting a "Cookies not enabled" error (from the Facebook screenshot) at login. Any idea how to work around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment