- 浏览: 363716 次
- 性别:
- 来自: 四川
文章分类
- 全部博客 (247)
- 数据库以及sql (11)
- java (48)
- 爬虫学习 (20)
- java编程 (28)
- python编程以及安装和配置 (27)
- oracle数据库 (32)
- mongodb基本操作 (4)
- linux学习 (7)
- easyUI (2)
- nodeJs (8)
- python学习 (16)
- 其他 (13)
- hadoop (1)
- svn (1)
- 汉字 (1)
- windows (2)
- jsp (5)
- fiddler (1)
- ETL (1)
- teamviewer (1)
- maven (4)
- GIT (2)
- datagrip (1)
- ocr (1)
- redis (3)
- mysql (3)
- linux (1)
- 数据服务 (0)
最新评论
package com.teamdev.jxbrowser.chromium.demo.lvmama_bjcp.店铺.住宿;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class GetUrlGetHotel {
/**
* web get请求
* */
public static String getHtmlGet(String urlStr) {
try {
URL url = new URL(urlStr);
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("GET");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
// 默认是 GET方式
con.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
con.setRequestProperty("Accept-Encoding", "gzip, deflate, sdch");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Cache-Control", "max-age=0");
con.setRequestProperty("Connection", "keep-alive");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Host", "s.lvmama.com");
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream(),"UTF-8");
//String parm = "type=all¤tPage="+pageIndex+"&totalCount="+ev_num+"&placeId=10034946" +
// "&productId=&placeIdType=PLACE&isPicture=&isBest=&isPOI=Y&isELong=Y";
//out.write(new String(parm.getBytes("utf-8")));
out.flush();
out.close();
BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(con.getInputStream()));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
byte[] arr = new byte[1024];
while((len=bis.read(arr))!= -1){
bos.write(arr,0,len);
bos.flush();
}
bos.close();
return bos.toString("utf-8");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 多个参数的web post请求
* */
public static String getHtmlPost(String pageIndex) {
try {
URL url = new URL("https://hotel.jd.com/api/json/getHotelList");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
// 默认是 GET方式
con.setRequestProperty("Accept", "application/json, text/javascript, */*; q=0.01");
con.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Connection", "keep-alive");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Cookie","cn=0; unpl=V2_ZzNtbUAFExN0DUFVfREPDWJTRggSA0sUfQ1CV3saXwUyUBFcclRCFXwUR1JnGloUZwIZXUZcRh1FCHZXchBYAWcCGllyBBNNIEwHDCRSBUE3XHxcFVUWF3RaTwEoSVoAYwtBDkZUFBYhW0IAKElVVTUFR21yVEMldQl2VHoYWQNnBxpfQmdzEkU4dlR5GV0AYDMTbUNnAUEpCkJWexpbSGcCE1hEV0cddwh2VUsa; __jdv=122270672|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_3ca7046079b94aedae9094521221db20|1532657751699; PCSYCityID=1; shshshfpa=a5c42043-fe72-ad41-b1e8-9dda3b0c262c-1532657753; ipLoc-djd=1-72-2799-0; shshshfp=546db3f16653ecbba5cab2e0d17f01a7; shshshsID=e92bfb065abe77c491cf64bdfa51a46a_2_1532657770541; shshshfpb=014d1bcf8df5532c759221ebb513446b881b3534352157d7b5af2ad7bb; __guid=107159195.3197066150622231000.1532657788366.921; cityName=%u5317%u4EAC%7C36; monitor_count=3; __jda=122270672.1004715931.1524121297.1531460818.1532657752.28; __jdb=122270672.7.1004715931|28.1532657752; __jdc=122270672; __jdu=1004715931; 3AB9D23F7A4B3C9B=I33RQ6RM6LCSWTGHWCWKVHO32GQPWZAEHB4WK5YDNWTGB3FIHBJ7SGFNW2QEI2OCI4BEFJT5A6RX4MOU6OFPFSAR74");
con.setRequestProperty("Host", "hotel.jd.com");
con.setRequestProperty("Origin", "https://hotel.jd.com");
con.setRequestProperty("Referer", "https://hotel.jd.com/list.html?cityId=36&cityName=%E5%8C%97%E4%BA%AC&checkInDate=2018-07-28&checkOutDate=2018-07-29&keyword=&poiType=&poiCode=");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
con.setRequestProperty("X-Requested-With", "XMLHttpRequest");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream(),"UTF-8");
String parm = "keyword=&cityId=36&checkInDate=2018-07-28&checkOutDate=2018-07-29&minPrice=" +
"&maxPrice=&stars=&pageSize=30&pageNum="+pageIndex+"&bedType=&amenities=&promotions=" +
"&themes=&breakfast=&order=&payMode=&poi=%5B%7B%22type%22%3A%2254%22%2C%22code%22%3A%222310%22%7D%5D";
out.write(new String(parm.getBytes("utf-8")));
out.flush();
out.close();
System.out.println(con.getResponseCode());
if(200 == con.getResponseCode()){
//得到输入流
InputStream is =con.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while(-1 != (len = is.read(buffer))){
baos.write(buffer,0,len);
baos.flush();
}
return baos.toString("utf-8");
}
//压缩
// BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(con.getInputStream()));
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// int len;
// byte[] arr = new byte[1024];
// while((len=bis.read(arr))!= -1){
// bos.write(arr,0,len);
// bos.flush();
// }
// bos.close();
// return bos.toString("utf-8");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
} /**
* json参数的app get请求
* */
public static String GetAPPGetByJsonText(String urlStr,String pageIndex) {
try {
URL url = new URL(urlStr);
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Cache-Control", "max-age=5");
con.setRequestProperty("ApplicationContext","eyJFbXBsb3llZUlkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5DdXJyZW50Q3VsdHVyZSI6MCwiTG9naW5EZXBhcnRtZW50IjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5PcmciOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJMb2dpblRlbmFudElkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5UaW1lIjoiL0RhdGUoMTUzMjA2NjY5NjMyMyswODAwKS8iLCJMb2dpblVzZXJDb2RlIjoiODYyNzcwMDMxMjcwNjM1QGIwOjg5OjAwOjk5OjI3OmU4IiwiTG9naW5Vc2VySUQiOiJhNmI3NTI3My0wMTUzLTQ0ZTQtYmUwZC0yOWNmMDA2ZWJiMjIiLCJTZXNzaW9uSUQiOiI4MDNhYmM2NS1iZjlkLTRlOWMtYmY1Ni0yNjhmYWY2NWU0OWQifQ==");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Accept-Encoding", "");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Host", "iustore.iuoooo.com");
con.setRequestProperty("User-Agent", "okhttp/3.2.0");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream());
//String xmlInfo = getXmlInfo();
//System.out.println("urlStr=" + urlStr);
//System.out.println("xmlInfo=" + xmlInfo);
out.write("{\"getStoreInfosSearchDTO\":{\"appId\":\"b3ad5aba-ae1e-4f4b-ba55-c5fb0375de3c\",\"areaCode\":\"3-110112\",\"filter\":{\"areaCode\":\"\",\"distance\":\"\",\"govGrade\":\"\",\"marketCode\":\"\",\"restaurantType\":\"\",\"tradeAreaCode\":\"\"},\"lat\":\"39.966983795166\",\"lng\":\"116.30883026123\",\"pageIndex\":"+pageIndex+",\"pageSize\":20,\"userId\":\"a6b75273-0153-44e4-be0d-29cf006ebb22\"}}");
//out.write(new String(xmlInfo.getBytes("ISO-8859-1")));
out.flush();
out.close();
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream()));
String line = "";
for (line = br.readLine(); line != null; line = br.readLine()) {
//System.out.println(line);
return line;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static String testPost(String urlStr,String pageIndex) {
try {
URL url = new URL(urlStr);
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Cache-Control", "max-age=5");
con.setRequestProperty("ApplicationContext","eyJFbXBsb3llZUlkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5DdXJyZW50Q3VsdHVyZSI6MCwiTG9naW5EZXBhcnRtZW50IjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5PcmciOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJMb2dpblRlbmFudElkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5UaW1lIjoiL0RhdGUoMTUzMjA2NjY5NjMyMyswODAwKS8iLCJMb2dpblVzZXJDb2RlIjoiODYyNzcwMDMxMjcwNjM1QGIwOjg5OjAwOjk5OjI3OmU4IiwiTG9naW5Vc2VySUQiOiJhNmI3NTI3My0wMTUzLTQ0ZTQtYmUwZC0yOWNmMDA2ZWJiMjIiLCJTZXNzaW9uSUQiOiI4MDNhYmM2NS1iZjlkLTRlOWMtYmY1Ni0yNjhmYWY2NWU0OWQifQ==");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Accept-Encoding", "");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Host", "iustore.iuoooo.com");
con.setRequestProperty("User-Agent", "okhttp/3.2.0");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream());
//String xmlInfo = getXmlInfo();
//System.out.println("urlStr=" + urlStr);
//System.out.println("xmlInfo=" + xmlInfo);
out.write("{\"getStoreInfosSearchDTO\":{\"appId\":\"b3ad5aba-ae1e-4f4b-ba55-c5fb0375de3c\",\"areaCode\":\"3-110112\",\"filter\":{\"areaCode\":\"\",\"distance\":\"\",\"govGrade\":\"\",\"marketCode\":\"\",\"restaurantType\":\"\",\"tradeAreaCode\":\"\"},\"lat\":\"39.966983795166\",\"lng\":\"116.30883026123\",\"pageIndex\":"+pageIndex+",\"pageSize\":20,\"userId\":\"a6b75273-0153-44e4-be0d-29cf006ebb22\"}}");
//out.write(new String(xmlInfo.getBytes("ISO-8859-1")));
out.flush();
out.close();
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream()));
String line = "";
for (line = br.readLine(); line != null; line = br.readLine()) {
//System.out.println(line);
return line;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
String url = "http://s.lvmama.com/hotel/C20180727O20180728P1U13?keyword=&mdd=%E5%8C%97%E4%BA%AC#list#list";
try {
System.out.println(getHtmlGet(url));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class GetUrlGetHotel {
/**
* web get请求
* */
public static String getHtmlGet(String urlStr) {
try {
URL url = new URL(urlStr);
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("GET");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
// 默认是 GET方式
con.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
con.setRequestProperty("Accept-Encoding", "gzip, deflate, sdch");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Cache-Control", "max-age=0");
con.setRequestProperty("Connection", "keep-alive");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Host", "s.lvmama.com");
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream(),"UTF-8");
//String parm = "type=all¤tPage="+pageIndex+"&totalCount="+ev_num+"&placeId=10034946" +
// "&productId=&placeIdType=PLACE&isPicture=&isBest=&isPOI=Y&isELong=Y";
//out.write(new String(parm.getBytes("utf-8")));
out.flush();
out.close();
BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(con.getInputStream()));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
byte[] arr = new byte[1024];
while((len=bis.read(arr))!= -1){
bos.write(arr,0,len);
bos.flush();
}
bos.close();
return bos.toString("utf-8");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 多个参数的web post请求
* */
public static String getHtmlPost(String pageIndex) {
try {
URL url = new URL("https://hotel.jd.com/api/json/getHotelList");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
// 默认是 GET方式
con.setRequestProperty("Accept", "application/json, text/javascript, */*; q=0.01");
con.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Connection", "keep-alive");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Cookie","cn=0; unpl=V2_ZzNtbUAFExN0DUFVfREPDWJTRggSA0sUfQ1CV3saXwUyUBFcclRCFXwUR1JnGloUZwIZXUZcRh1FCHZXchBYAWcCGllyBBNNIEwHDCRSBUE3XHxcFVUWF3RaTwEoSVoAYwtBDkZUFBYhW0IAKElVVTUFR21yVEMldQl2VHoYWQNnBxpfQmdzEkU4dlR5GV0AYDMTbUNnAUEpCkJWexpbSGcCE1hEV0cddwh2VUsa; __jdv=122270672|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_3ca7046079b94aedae9094521221db20|1532657751699; PCSYCityID=1; shshshfpa=a5c42043-fe72-ad41-b1e8-9dda3b0c262c-1532657753; ipLoc-djd=1-72-2799-0; shshshfp=546db3f16653ecbba5cab2e0d17f01a7; shshshsID=e92bfb065abe77c491cf64bdfa51a46a_2_1532657770541; shshshfpb=014d1bcf8df5532c759221ebb513446b881b3534352157d7b5af2ad7bb; __guid=107159195.3197066150622231000.1532657788366.921; cityName=%u5317%u4EAC%7C36; monitor_count=3; __jda=122270672.1004715931.1524121297.1531460818.1532657752.28; __jdb=122270672.7.1004715931|28.1532657752; __jdc=122270672; __jdu=1004715931; 3AB9D23F7A4B3C9B=I33RQ6RM6LCSWTGHWCWKVHO32GQPWZAEHB4WK5YDNWTGB3FIHBJ7SGFNW2QEI2OCI4BEFJT5A6RX4MOU6OFPFSAR74");
con.setRequestProperty("Host", "hotel.jd.com");
con.setRequestProperty("Origin", "https://hotel.jd.com");
con.setRequestProperty("Referer", "https://hotel.jd.com/list.html?cityId=36&cityName=%E5%8C%97%E4%BA%AC&checkInDate=2018-07-28&checkOutDate=2018-07-29&keyword=&poiType=&poiCode=");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
con.setRequestProperty("X-Requested-With", "XMLHttpRequest");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream(),"UTF-8");
String parm = "keyword=&cityId=36&checkInDate=2018-07-28&checkOutDate=2018-07-29&minPrice=" +
"&maxPrice=&stars=&pageSize=30&pageNum="+pageIndex+"&bedType=&amenities=&promotions=" +
"&themes=&breakfast=&order=&payMode=&poi=%5B%7B%22type%22%3A%2254%22%2C%22code%22%3A%222310%22%7D%5D";
out.write(new String(parm.getBytes("utf-8")));
out.flush();
out.close();
System.out.println(con.getResponseCode());
if(200 == con.getResponseCode()){
//得到输入流
InputStream is =con.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while(-1 != (len = is.read(buffer))){
baos.write(buffer,0,len);
baos.flush();
}
return baos.toString("utf-8");
}
//压缩
// BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(con.getInputStream()));
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// int len;
// byte[] arr = new byte[1024];
// while((len=bis.read(arr))!= -1){
// bos.write(arr,0,len);
// bos.flush();
// }
// bos.close();
// return bos.toString("utf-8");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
} /**
* json参数的app get请求
* */
public static String GetAPPGetByJsonText(String urlStr,String pageIndex) {
try {
URL url = new URL(urlStr);
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Cache-Control", "max-age=5");
con.setRequestProperty("ApplicationContext","eyJFbXBsb3llZUlkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5DdXJyZW50Q3VsdHVyZSI6MCwiTG9naW5EZXBhcnRtZW50IjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5PcmciOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJMb2dpblRlbmFudElkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5UaW1lIjoiL0RhdGUoMTUzMjA2NjY5NjMyMyswODAwKS8iLCJMb2dpblVzZXJDb2RlIjoiODYyNzcwMDMxMjcwNjM1QGIwOjg5OjAwOjk5OjI3OmU4IiwiTG9naW5Vc2VySUQiOiJhNmI3NTI3My0wMTUzLTQ0ZTQtYmUwZC0yOWNmMDA2ZWJiMjIiLCJTZXNzaW9uSUQiOiI4MDNhYmM2NS1iZjlkLTRlOWMtYmY1Ni0yNjhmYWY2NWU0OWQifQ==");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Accept-Encoding", "");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Host", "iustore.iuoooo.com");
con.setRequestProperty("User-Agent", "okhttp/3.2.0");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream());
//String xmlInfo = getXmlInfo();
//System.out.println("urlStr=" + urlStr);
//System.out.println("xmlInfo=" + xmlInfo);
out.write("{\"getStoreInfosSearchDTO\":{\"appId\":\"b3ad5aba-ae1e-4f4b-ba55-c5fb0375de3c\",\"areaCode\":\"3-110112\",\"filter\":{\"areaCode\":\"\",\"distance\":\"\",\"govGrade\":\"\",\"marketCode\":\"\",\"restaurantType\":\"\",\"tradeAreaCode\":\"\"},\"lat\":\"39.966983795166\",\"lng\":\"116.30883026123\",\"pageIndex\":"+pageIndex+",\"pageSize\":20,\"userId\":\"a6b75273-0153-44e4-be0d-29cf006ebb22\"}}");
//out.write(new String(xmlInfo.getBytes("ISO-8859-1")));
out.flush();
out.close();
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream()));
String line = "";
for (line = br.readLine(); line != null; line = br.readLine()) {
//System.out.println(line);
return line;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static String testPost(String urlStr,String pageIndex) {
try {
URL url = new URL(urlStr);
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Cache-Control", "max-age=5");
con.setRequestProperty("ApplicationContext","eyJFbXBsb3llZUlkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5DdXJyZW50Q3VsdHVyZSI6MCwiTG9naW5EZXBhcnRtZW50IjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5PcmciOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJMb2dpblRlbmFudElkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiTG9naW5UaW1lIjoiL0RhdGUoMTUzMjA2NjY5NjMyMyswODAwKS8iLCJMb2dpblVzZXJDb2RlIjoiODYyNzcwMDMxMjcwNjM1QGIwOjg5OjAwOjk5OjI3OmU4IiwiTG9naW5Vc2VySUQiOiJhNmI3NTI3My0wMTUzLTQ0ZTQtYmUwZC0yOWNmMDA2ZWJiMjIiLCJTZXNzaW9uSUQiOiI4MDNhYmM2NS1iZjlkLTRlOWMtYmY1Ni0yNjhmYWY2NWU0OWQifQ==");
con.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
con.setRequestProperty("Accept-Encoding", "");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Host", "iustore.iuoooo.com");
con.setRequestProperty("User-Agent", "okhttp/3.2.0");
OutputStreamWriter out = new OutputStreamWriter(con
.getOutputStream());
//String xmlInfo = getXmlInfo();
//System.out.println("urlStr=" + urlStr);
//System.out.println("xmlInfo=" + xmlInfo);
out.write("{\"getStoreInfosSearchDTO\":{\"appId\":\"b3ad5aba-ae1e-4f4b-ba55-c5fb0375de3c\",\"areaCode\":\"3-110112\",\"filter\":{\"areaCode\":\"\",\"distance\":\"\",\"govGrade\":\"\",\"marketCode\":\"\",\"restaurantType\":\"\",\"tradeAreaCode\":\"\"},\"lat\":\"39.966983795166\",\"lng\":\"116.30883026123\",\"pageIndex\":"+pageIndex+",\"pageSize\":20,\"userId\":\"a6b75273-0153-44e4-be0d-29cf006ebb22\"}}");
//out.write(new String(xmlInfo.getBytes("ISO-8859-1")));
out.flush();
out.close();
BufferedReader br = new BufferedReader(new InputStreamReader(con
.getInputStream()));
String line = "";
for (line = br.readLine(); line != null; line = br.readLine()) {
//System.out.println(line);
return line;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
String url = "http://s.lvmama.com/hotel/C20180727O20180728P1U13?keyword=&mdd=%E5%8C%97%E4%BA%AC#list#list";
try {
System.out.println(getHtmlGet(url));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
发表评论
-
采集ymx商品信息
2018-08-29 15:28 502public static void main(String[ ... -
根据百度加密url, 获取真实url
2018-08-06 10:46 0public static void main(String[ ... -
fiddler 抓取 手机https 数据包 完美解决
2018-08-03 12:43 3014转:https://jingyan.baidu.com ... -
无忧代理IP
2018-07-30 16:19 0http://api.ip.data5u.com/dynami ... -
post请求加json参数方式二
2018-07-24 14:02 1968package com.teamdev.jxbrowser.c ... -
post请求加json参数或xml参数
2018-07-20 18:21 1249import java.io.BufferedReader; ... -
jd编号
2017-11-02 17:59 499京东店铺:https://mall.jd.com/index- ... -
清除google缓存
2017-10-26 11:20 6221.进入 chrome://net-internals/#dn ... -
adb server is out of date. killing... 本地连接夜神模拟器失败、超时
2017-06-19 10:43 1497原因:1.模拟器器设置了代理;2.主要是模拟器和sdk 的ad ... -
fiddler抓取的https请求 数据乱码问题解决方案
2017-06-09 09:44 7200参考地址:http://blog.csdn.net/SomeO ... -
chromium.Browser 禁止加载图片,提升加载速度
2017-05-25 11:29 1165package com.teamdev.jxbrowser.c ... -
chrome 禁止加载网页图片 解决办法
2017-05-25 11:18 23261.在谷歌浏览器中输入:chrome://settings/c ... -
开源爬虫框架的优缺点?
2017-03-22 14:46 796开源爬虫框架各有什么优缺点? 作者:老夏 开发网络爬 ... -
反爬虫
2017-03-17 10:34 6701. 伪装user agent User agen ... -
爬虫被封禁原因
2017-03-17 09:37 1515爬虫被封禁常见原因 1. ... -
App数据抓取
2017-03-17 09:32 1063思路: 通过fiddler抓包 ... -
八爪鱼规则学习
2017-03-08 13:44 8241.八爪鱼采集器是任何一个需要从网页获取信息的人都必备的采集工 ... -
java模拟jquery请求动作(模拟点击、选择下拉)
2016-12-29 14:40 4023package com.teamdev.jxbrowser.c ... -
httpclient
2016-11-01 16:37 743package com.teamdev.jxbrowser.c ... -
jsoup + json 解析网页
2016-11-01 16:25 1265package com.teamdev.jxbrowser.c ...
相关推荐
苹果JBL大无所不能遥控器操作说明。解决好多人不会使用遥控操作的问题。
让迅雷无所不能下载、通吃一切 让迅雷无所不能下载、通吃一切
一款很好的电脑测试软件无所不能~~收了吧~不看会后悔
让迅雷无所不能下载.rar 网上找到的评价还不错的一个补丁。。。共享一下。。。 (本人没用过)
迅雷5专用让迅雷无所不能下载,迅雷支持专用链接,里面有使用说明。
让迅雷无所不能的工具 迅雷下载其他资源 比如电驴 快车等等
VB无所不能系列收集于网络,全文共7部分,包含原码。 主要内容: 1、指针 2、图像格式转换 3、获取消息钩子 4、透明和半透明窗体 5、创建标准DLL 6、监控运行程序 7、多线程
网络精选教程,希望大家不要忘记VB,包括GDI绘画等详解的例子
无所不能 相当强大 目前最强大内容最丰富的超级模块
U盘无所不能,用来提供u盘性能的提升与一些你想不到的事情
智慧能源-无所不能 完整
ChatGPT 真能上天入地?无所不能?
互联网 智慧能源-无所不能 .pptx
能源互联网白皮书-to 无所不能.zip
能源互联网白皮书-to 无所不能.pptx
360安全浏览器4.0新版 体验无所不能.docx
人每天有40%的行为并不是真正由决定促成的,而是出于习惯。...成功并不需要做对每一件事情,而是要辨别出一些重要的优先因素,并将其变成有力的杠杆。你的习惯对了 你无所不能——习惯的力量ppt模板。
构建伟大,无所不能 Jenkins是开源CI&CD软件领导者, 提供超过1000个插件来支持构建、部署、自动化, 满足任何项目的需要。 持续集成和持续交付 作为一个可扩展的自动化服务器,Jenkins 可以用作简单的 CI 服务器,...