Giter Site home page Giter Site logo

renrenlogin's Introduction

##renrenlogin

#登录人人网

#Install:

npm install renrenlogin

#Usage:

1.用账号密码登录

var fs=require('fs');

var Login=new (require('renrenlogin').INST)();

//如果账号是具有个人和公共主页双重身份的,

// 要登公共主页时把isPage设为true,其他情况都可不设isPage或设为false

var account={

email:'账号',

passwd:'密码',

isPage:false

};

Login.setAccount(account);

Login.onekeyLogin(function(err,info){

console.log(info.logined);

//把登录后的用户信息保存到文件中

fs.writeFileSync('info.txt',JSON.stringify(info,null,4), 'utf8');

});

2.从已保存到文件中的Cookie登录

//从持久化的cookie信息直接登录,不需要提交密码信息(如果发现cookie已经失效了,则会重新尝试密码登录)

function loginFromCookie(){

var account=JSON.parse(fs.readFileSync('info.txt','utf8'));

Login.setAccount(account);

Login.onekeyLogin(function(err,info){

    console.log(info.logined);

});

}

返回后的info中含有Cookie对象,这是request模块的内置cookie管理器。

后续要发起请求时建议使用request模块,只需把这个返回的Cookie设为request的默认cookie即可。

var request=require('request');

request=request.defaults({

jar:info.Cookie

});

request('http://www.renren.com',function(){});

///...

有问题邮件我[email protected]

renrenlogin's People

Contributors

sxyizhiren avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.