- 浏览: 373521 次
- 性别:
- 来自: 四川
文章分类
- 全部博客 (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 524public static void main(String[ ... -
根据百度加密url, 获取真实url
2018-08-06 10:46 0public static void main(String[ ... -
fiddler 抓取 手机https 数据包 完美解决
2018-08-03 12:43 3048转:https://jingyan.baidu.com ... -
无忧代理IP
2018-07-30 16:19 0http://api.ip.data5u.com/dynami ... -
post请求加json参数方式二
2018-07-24 14:02 2098package com.teamdev.jxbrowser.c ... -
post请求加json参数或xml参数
2018-07-20 18:21 1266import java.io.BufferedReader; ... -
jd编号
2017-11-02 17:59 541京东店铺:https://mall.jd.com/index- ... -
清除google缓存
2017-10-26 11:20 6881.进入 chrome://net-internals/#dn ... -
adb server is out of date. killing... 本地连接夜神模拟器失败、超时
2017-06-19 10:43 1516原因:1.模拟器器设置了代理;2.主要是模拟器和sdk 的ad ... -
fiddler抓取的https请求 数据乱码问题解决方案
2017-06-09 09:44 7287参考地址:http://blog.csdn.net/SomeO ... -
chromium.Browser 禁止加载图片,提升加载速度
2017-05-25 11:29 1205package com.teamdev.jxbrowser.c ... -
chrome 禁止加载网页图片 解决办法
2017-05-25 11:18 23531.在谷歌浏览器中输入:chrome://settings/c ... -
开源爬虫框架的优缺点?
2017-03-22 14:46 823开源爬虫框架各有什么优缺点? 作者:老夏 开发网络爬 ... -
反爬虫
2017-03-17 10:34 6941. 伪装user agent User agen ... -
爬虫被封禁原因
2017-03-17 09:37 1551爬虫被封禁常见原因 1. ... -
App数据抓取
2017-03-17 09:32 1106思路: 通过fiddler抓包 ... -
八爪鱼规则学习
2017-03-08 13:44 8551.八爪鱼采集器是任何一个需要从网页获取信息的人都必备的采集工 ... -
java模拟jquery请求动作(模拟点击、选择下拉)
2016-12-29 14:40 4082package com.teamdev.jxbrowser.c ... -
httpclient
2016-11-01 16:37 773package com.teamdev.jxbrowser.c ... -
jsoup + json 解析网页
2016-11-01 16:25 1298package com.teamdev.jxbrowser.c ...
相关推荐
苹果JBL“无所不能”遥控器是一款功能强大的遥控设备,适用于多种场合。通过本文详细介绍的操作指南和安全须知,使用者可以更好地了解如何正确、安全地使用这款遥控器,从而获得更好的用户体验。在日常使用过程中,...
总的来说,"让迅雷无所不能下载"的补丁可能是一种针对迅雷的优化工具,旨在扩展其下载能力。然而,考虑到安全性和合法性,用户在使用这类工具时应保持警惕,避免潜在的风险。如果需要增强迅雷的下载能力,建议关注...
让迅雷无所不能下载、通吃一切 让迅雷无所不能下载、通吃一切
这两种下载方式与迅雷基于BTP(BitTorrent Protocol)的下载机制不同,因此直接在迅雷中打开这些链接可能无效。 为了让迅雷下载电驴和快车的资源,可以采用以下几种方法: 1. **转换链接**:有些在线服务或软件...
标题中的“电脑测试软件很好用无所不能”表明我们讨论的是一款功能强大的计算机系统诊断和测试工具,它能够全面地分析和评估电脑硬件和软件的性能。这类软件通常包含多个模块,用于测试处理器、内存、硬盘、显卡等...
根据提供的文件信息,以下是关于VB无所不能系列的详细知识点。 ### 1. 指针 指针在VB中的使用与C语言等其他编程语言中的使用有所不同,因为VB是一种高级语言,它对内存访问进行了封装。在VB中,可以通过API调用和...
网络精选教程,希望大家不要忘记VB,包括GDI绘画等详解的例子
无所不能 相当强大 目前最强大内容最丰富的超级模块
而“让迅雷无所不能【绿色补丁】”显然是一种针对迅雷软件的修改或优化,旨在扩展其功能,尤其是使其能够处理原本专属于其他下载工具,如快车(FlashGet)的下载链接。 首先,我们要理解什么是“绿色补丁”。在...
【快乐网管之无所不能软件】是一款针对初级用户的自动化工具,类似于知名的【按键精灵】,旨在简化用户在日常计算机操作中的复杂流程。该软件通过模拟鼠标点击和键盘输入,能够执行一系列预先设定好的任务,极大地...
智慧能源-无所不能 完整
ChatGPT 真能上天入地?无所不能?
然而,为了满足题目要求,我们可以从中提取一些相关的人生智慧和心理成长的建议,这些内容虽然不属于IT领域,却能为个人成长提供指导和启示,进而间接对个人在职场中的表现和决策能力产生积极影响。 一、个人成长与...
总的来说,"万能编程器软件---无所不能"不仅是一个工具,更是一种解决方案,它简化了对各种类型芯片编程的过程,提高了开发效率。无论是用于学习、原型设计还是大规模生产,这样的软件都是电子工程师的得力助手。其...
标题中的“真正的无所不能!”可能是指这个压缩包包含了大量的IT学习资源,涵盖了多个领域的知识,而描述中的“我所下的所有书的整合!绝对经典!只要你能想到的这里面都有!”进一步证实了这一点,说明这个集合包含...
能源互联网白皮书-to 无所不能.pptx
它会自动为下载的数据分配内存缓冲区,减少硬盘读写次数,保护硬盘的同时提高了下载效率。同时,迅雷5还具备断点续传功能,即使下载过程中因网络问题中断,也能在恢复连接后继续从上次中断的地方下载,无需重新开始...