这个,前几天有个人出2000软妹币让我做这个功能,应该是风控系统需要吧,我就鼓捣起来,先分析了一下京东的请求,发现未加密密码,呵呵呵呵呵呵,故意的吧喂,那我就不客气哦

项目百度云地址:http://pan.baidu.com/s/1kVGtgRt

上代码:

主攻登录的:

package clent.http;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStream;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

import org.apache.http.Consts;

import org.apache.http.Header;

import org.apache.http.HeaderElement;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.ParseException;

import org.apache.http.client.ClientProtocolException;

import org.apache.http.client.entity.UrlEncodedFormEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.message.BufferedHeader;

import org.apache.http.util.EntityUtils;

import org.jsoup.Jsoup;

import org.jsoup.nodes.Element;

import org.jsoup.select.Elements;

public class LoginJD {

CloseableHttpClient httpClient=null;

Fromdata form=new Fromdata();

String loginUrl = "http://passport.jd.com/uc/login";

String redirectURL="http://order.jd.com/center/list.action";

String home="http://home.jd.com/";

public void initpage(String username,String pwd)

{

String url="http://passport.jd.com/uc/login";

HttpGet httpPost=new HttpGet(url);

httpPost.setHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36");

String html="";

try {

CloseableHttpResponse response = httpClient.execute(httpPost);

HttpEntity entity = response.getEntity();

html=EntityUtils.toString(entity, "utf-8");

Elements els=Jsoup.parse(html).getElementsByTag("input");

for(Element e:els)

{

String value=e.val();

String name=e.attr("name");

if(!"uuid".equals(name)&&!"machineNet".equals(name)&&!"machineCpu".equals(name)&&!"machineDisk".equals(name)&&!"eid".equals(name)&&!"fp".equals(name)&&!"_t".equals(name)&&!"loginType".equals(name)&&!"loginname".equals(name)&&!"nloginpwd".equals(name)&&!"loginpwd".equals(name)&&!"chkRememberMe".equals(name)&&!"authcode".equals(name))

{

form.key=name;

form.value=value;

}

form.init(name, value);

form.setLoginname(username);

form.setNloginpwd(pwd);

form.setLoginpwd(pwd);

}

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

System.out.println(html);

}

public void login()

{

String url=UrlConfig.loginurl;

url=url.replace("#{uuid}", this.form.getUuid());

HttpPost httpPost=new HttpPost(url);

httpPost.setHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36");

UrlEncodedFormEntity entity = new UrlEncodedFormEntity(this.form.getbase(), Consts.UTF_8);

try {

System.out.println(EntityUtils.toString(entity, "utf-8"));

} catch (ParseException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (IOException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

httpPost.setEntity(entity);

String html="";

try {

CloseableHttpResponse response = httpClient.execute(httpPost);

HttpEntity entitySort = response.getEntity();

html=EntityUtils.toString(entitySort, "utf-8");

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

System.out.println("++++++\t"+html);

}

public void getImage()

{

String url=UrlConfig.imageurl;

System.out.println(url);

url=url.replace("#{acid}", this.form.getUuid()).replace("#{uid}", this.form.getUuid()).replace("#{time}", System.currentTimeMillis()+"");

System.out.println(url);

try {

HttpGet httpimg = new HttpGet(url);

httpimg.setHeader("Connection", "keep-alive");

httpimg.setHeader("Host", "authcode.jd.com");

httpimg.setHeader("Referer", "https://passport.jd.com/uc/login?ltype=logout");

httpimg.setHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36");

HttpResponse responseimg =  httpClient.execute(httpimg);

File file=new File("D:\\ss.gif");

OutputStream out=new FileOutputStream(file);

responseimg.getEntity().writeTo(out);

out.close();

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

public String  getpage_1(String url)

{

HttpGet httpPost=new HttpGet(url);

httpPost.setHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36");

try {

CloseableHttpResponse response = httpClient.execute(httpPost);

BufferedHeader locationHeader = (BufferedHeader) response.getFirstHeader("Location");

if (locationHeader == null) {

return null;

}

return locationHeader.getValue();

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

return null;

}

public void  getpage_2(String url)

{

HttpGet httpPost=new HttpGet(url);

httpPost.setHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36");

String html="";

try {

CloseableHttpResponse response = httpClient.execute(httpPost);

HttpEntity entitySort = response.getEntity();

html=EntityUtils.toString(entitySort, "utf-8");

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

System.out.println("getpage_2\n"+html);

}

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);//输入

LoginJD jd=new LoginJD();

jd.httpClient=HttpClients.createDefault();

jd.initpage("xxxxxx","xxxxxxxxxxx");

jd.getImage();

String validate="";

validate = scan.next();

jd.form.setAuthcode(validate);

jd.login();

jd.getpage_2(jd.home);

}

}

这就登录成功了,亲测可以没问题,鹅鹅鹅,强哥还是敦促开发人员填了这个坑吧

需要完整的代码可以留言哦,还有,网上其他的一些登录京东的,有问题,估计是那人故意留的坑

java模拟登陆京东_使用httpclient模拟登录京东帐户并抓取帐户信息相关推荐

  1. winform模拟登陆网页_用c#模拟手机app向网站登录,如何写?

    使用fiddle 4抓的包: POST /pdalogin/p/common/loginandpremission HTTP/1.1 Connection: Keep-Alive Accept-Enc ...

  2. node抓取58同城信息_如何使用标准库和Node.js轻松抓取网站以获取信息

    node抓取58同城信息 网络抓取工具是一种工具,可让我们选择网站的非结构化数据并将其转换为结构化数据库. 那么,网络刮板将在哪里派上用场呢? 我列出了我最喜欢的用例,以使您对启动自己的应用感到兴奋! ...

  3. java爬虫 京东_教您使用java爬虫gecco抓取JD全部商品信息(一)

    #教您使用java爬虫gecco抓取JD全部商品信息(一) ##gecco爬虫 如果对gecco还没有了解可以参看一下gecco的github首页.gecco爬虫十分的简单易用,JD全部商品信息的抓取 ...

  4. 教您使用java爬虫gecco抓取JD全部商品信息

    转自:http://www.geccocrawler.com/demo-jd/ gecco爬虫 如果对gecco还没有了解可以参看一下gecco的github首页.gecco爬虫十分的简单易用,JD全 ...

  5. Java爬虫抓取豆瓣读书信息

    要求: Java爬虫抓取豆瓣读书信息中关于"编程,算法,互联网"评分最高的前100本书(要求评论数量大于1000) 实现思路: 1.通过手动打开豆瓣读书的主页面 https://b ...

  6. python获取app信息的库_基于python3抓取pinpoint应用信息入库

    这篇文章主要介绍了基于python3抓取pinpoint应用信息入库,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 Pinpoint是用Java编写 ...

  7. python实现食品推荐_通过Python语言实现美团美食商家数据抓取

    首先,我们先来打开美团美食商家页面,来分析一下. 如上面所提供的URL即为美团美食商家页面.或者我们通过美团官网打开一个美团美食商家页面,打开步骤如下:1.打开浏览器,输入 即可打开美团北京首页 2. ...

  8. java爬虫之WebMagic实战抓取前程无忧招聘信息

    webmagic教程 http://webmagic.io/docs/zh/ 入门案例 package com.hikktn.webmagic;import us.codecraft.webmagic ...

  9. 教您使用java爬虫gecco抓取JD全部商品信息(一)

    摘要: 如果对gecco还没有了解可以参看一下gecco的github首页,https://github.com/xtuhcy/gecco.gecco爬虫十分的简单易用,JD全部商品信息的抓取9个类就 ...

  10. winform模拟登陆网页_【教程】模拟登陆网站 之 C#版(内含两种版本的完整的可运行的代码)...

    之前已经介绍过了网络相关的一些基础知识了: 以及简单的网页内容抓取,用C#是如何实现的: 现在接着来介绍,以模拟登陆百度首页: 为例,说明如何通过C#模拟登陆网站. 不过,此处需要介绍一下此文前提: ...

最新文章

  1. 编程之美:无差错二分查找
  2. Android数据存储之SharedPreferences
  3. 云+技术沙龙:计算机视觉的原理及最佳实践
  4. 企业应用系统总体设计-----面向对象方法
  5. openresty开发系列22--lua的元表
  6. 程序员最讨厌的9句话,你可有补充? 1
  7. 数论一之定理证明——裴蜀/威尔逊/费马/扩展欧几里得/[扩展]欧拉/[扩展]中国剩余定理,欧拉函数,逆元,剩余系,筛法
  8. LeetCode 326. Power of Three
  9. ux设计师薪水_我是如何从33岁的博物馆导游变成专业的Web开发人员和UX设计师的:我的…...
  10. [转载] 深入理解Linux修改hostname
  11. linux 磁盘被挂载2个目录,Linux检测并挂载第二块硬盘的步骤
  12. esp连接服务器的协议,【零知ESP8266教程】WIFI TCP协议通信 TCP服务器示例
  13. 决策树ID3算法实现与讨论(完整代码与数据)
  14. cm-14.1 Android系统启动过程分析(二)-Zygote进程启动过程
  15. 章文嵩博士和他背后的负载均衡(LOAD BANLANCER)帝国
  16. 物联网案例(三):工业物联网中故障预警与风险管理的规范性分析
  17. 计算机硬盘读取超慢,如何解决电脑硬盘速度慢
  18. 图灵机器人 mysql_如何在微信小程序中制作图灵机器人?
  19. 文件创建时间、修改时间、访问时间的定义
  20. 上海华腾软件系统有限公司怎么样

热门文章

  1. java基础教程推荐_推荐Java入门视频教程
  2. Neutron IPAM源码分析
  3. 编写windows版ANE
  4. 数据结构——绪论、时间复杂度
  5. 阿里云赵明山:详解灵活可插拔的渐进式发布框架OpenKruise Rollout
  6. Leetcode 714
  7. 【教你如何用驱动人生解决驱动问题】
  8. ubuntu20.04中安装划词翻译_Chrome翻译插件【沙拉查词】amp;【彩云小译】
  9. 用 HTML 做一个表单模板
  10. 论文阅读-2020ICRL-Neural execution of graph algorithms