Java模拟新浪微博登陆抓取数据

Posted ZeroTeam_麒麟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java模拟新浪微博登陆抓取数据相关的知识,希望对你有一定的参考价值。

Java模拟新浪微博登陆抓取数据

前言:

 兄弟们来了来了,最近有人在问如何模拟新浪微博登陆抓取数据,我听后默默地抽了一口老烟,暗暗的对自己说,老汉是时候该你出场了,所以今天有时间就整理整理,浅谈一二。

首先:

 要想登陆新浪微博需要预登陆,即是将账号base64加密,密码rsa加密以及请求http://login.sina.com.cn/sso/prelogin.php链接获取一些登陆需要参数,返回的接送字符串如:

"retcode":0,"servertime":1487292003,"pcid":"gz-9e1f24c9acdefb111e1c8078558c7d9c0bf2","nonce":"VHRDG1","pubkey":"EB2A38568661887FA180BDDB5CABD5F21C7BFD59C090CB2D245A87AC253062882729293E5506350508E7F9AA3BB77F4333231490F915F6D63C55FE2F08A49B353F444AD3993CACC02DB784ABBB8E42A9B1BBFFFB38BE18D78E87A0E41B9B8F73A928EE0CCEE1F6739884B9777E4FE9E88A1BBE495927AC4A799B3181D6442443","rsakv":"1330428213","is_openlock":0,"lm":1,"smsurl":"https:\\/\\/login.sina.com.cn\\/sso\\/msglogin?entry=weibo&mobile=18360903574&s=ea7a2e91c5f1d6da7f42aa87fe6963d0","showpin":0,"exectime":222

 

,接下来是预登陆处理代码:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 /**      * @author LongJin      * @description 初始登录信息<br> 返回false说明初始失败      * @return      */      public  boolean  preLogin()          boolean  flag =  false ;          try               su =  new  String(Base64.encodeBase64(URLEncoder.encode(username,  "UTF-8" ).getBytes()));              String url =  "http://login.sina.com.cn/sso/prelogin.php?entry=weibo&rsakt=mod&checkpin=1&"  +                           "client=ssologin.js(v1.4.5)&_="  + getTimestamp();              url +=  "&su="  + su;              String content;              content = HttpUtils.getRequest(client, url);              System.out.println( "content------------"  + content);              JSONObject json = JSONObject.fromObject(content);              System.out.println(json);              servertime = json.getLong( "servertime" );              nonce = json.getString( "nonce" );              rsakv = json.getString( "rsakv" );              pubkey = json.getString( "pubkey" );              flag = encodePwd();            catch  (UnsupportedEncodingException e)              System.out.println( "抛出UnsupportedEncoding异常" );            catch  (ClientProtocolException e)              System.out.println( "抛出ClientProtocol异常" );            catch  (IOException e)              System.out.println( "抛出IO异常" ); Python实现新浪微博登陆!验证码?反爬?在我这里是不存在的!

新浪微博模拟登陆+数据抓取(java实现)

微博登陆分析

微博登陆步骤

登陆新浪微博

php实现新浪微博授权登录

(c)2006-2024 SYSTEM All Rights Reserved IT常识