Skip to content

Instantly share code, notes, and snippets.

@makevoid
Created September 26, 2013 21:48
Show Gist options
  • Select an option

  • Save makevoid/6721071 to your computer and use it in GitHub Desktop.

Select an option

Save makevoid/6721071 to your computer and use it in GitHub Desktop.
Mechanize scraping example - scraping Workflowy json of everything
require 'mechanize'
require 'json'
require 'pp'
@agent = Mechanize.new
def login
page = @agent.get "https://workflowy.com"
form = page.forms.first
form.username = "makevoid@gmail.com"
form.password = "asdasd"
page2 = form.submit
# p page2.body =~ /asdasdasd/
end
login
def reload
page = @agent.get "https://workflowy.com/get_initialization_data"
json = JSON.parse page.body
json = json["projectTreeData"]["mainProjectTreeInfo"]["rootProjectChildren"]
$json = json
end
reload
$json.map{ |elem| elem["ch"].map{ |elem| elem["nm"] } }.flatten
@makevoid

Copy link
Copy Markdown
Author

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