Skip to content

Instantly share code, notes, and snippets.

@WayneCui
Created January 13, 2015 12:19
Show Gist options
  • Save WayneCui/97c8c98adde3837b2596 to your computer and use it in GitHub Desktop.
Save WayneCui/97c8c98adde3837b2596 to your computer and use it in GitHub Desktop.
login to douban.com
Rebol [
title: %login2douban.reb
date: 13-Jan-2015
author: "Graham Chiu / Cui Wen"
purpose: {login to douban.com}
description: { based on Graham Chiu's login2so.reb: https://github.com/gchiu/Rebol3/blob/master/scripts/login2so.reb}
]
print "loading modified prot-http.r3"
do https://raw.githubusercontent.com/gchiu/Rebol3/master/protocols/prot-http.r3
print "loading altwebform.r"
do http://reb4.me/r3/altwebform.r
login-page: http://www.douban.com/accounts/login
doumail: http://www.douban.com/doumail/
account: xxx@xxx.com
password: 111111
data: to-string read login-page
postdata: to-webform reduce ['form_email account 'form_password password 'login {登录} ]
if error? err: try [
result: to-string write http://www.douban.com/accounts/login postdata
probe result
][
probe err
cookiejar: reform err/arg2/headers/set-cookie
parse cookiejar [ to "dbcl2=" copy cookiejar to ";" ]
probe cookiejar
result: to-string write doumail compose/deep [GET [cookie: (cookiejar)]]
probe result
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment