Skip to content

Instantly share code, notes, and snippets.

@vijayrudraraju
Forked from hnaohiro/facebook_scraping.coffee
Created February 27, 2016 10:07
Show Gist options
  • Save vijayrudraraju/ab198364f4ecd6689ed4 to your computer and use it in GitHub Desktop.
Save vijayrudraraju/ab198364f4ecd6689ed4 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment