public class HttpApi
{
public String get(String url)
{
StringBuffer buffer = new StringBuffer();
InputStreamReader isr = null;
try {
URL urlObj = new URL(url);
URLConnection uc = urlObj.openConnection();
uc.setConnectTimeout(10000);
uc.setReadTimeout(10000);
isr = new InputStreamReader(uc.getInputStream(), "utf-8");
BufferedReader reader = new BufferedReader(isr);
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line + "\n");
}
} catch (Exception e) {
// Toast("错误链接:"+url);
e.printStackTrace();
} finally {
try {
if (null != isr) {
isr.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
if(buffer.length()==0)return buffer.toString();
buffer.delete(buffer.length()-1,buffer.length());
return buffer.toString();
}
public static String pet(String url)
{
try
{
URL u = new URL(url);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
conn.setRequestProperty("Accept-Encoding","gzip");
conn.setRequestProperty("Connection","Keep-Alive");
conn.setRequestProperty("User-Agent","Apache-HttpClient/UNAVAILABLE (java 1.4)");
conn.connect();
InputStream is = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String temp;
StringBuffer buf = new StringBuffer();
while ((temp = reader.readLine()) != null)
{
buf.append(temp);
}
is.close();
return buf.toString();
}
catch (Exception e)
{}
return null;
}
public String post(String url,String params)
{
try {
URL urlObjUrl=new URL(url);
URLConnection connection =urlObjUrl.openConnection();
connection.setDoOutput(true);
OutputStream os=connection.getOutputStream();
os.write(params.getBytes());
os.close();
InputStream iStream=connection.getInputStream();
byte[] b=new byte[1024];
int len;
StringBuilder sb=new StringBuilder();
while ((len=iStream.read(b))!=-1) {
sb.append(new String(b,0,len));
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String getWithAgent(String url,String Agent)
{
StringBuffer buffer = new StringBuffer();
InputStreamReader isr = null;
try {
URL urlObj = new URL(url);
URLConnection uc = urlObj.openConnection();
uc.setRequestProperty("User-agent",Agent);
uc.setConnectTimeout(10000);
uc.setReadTimeout(10000);
isr = new InputStreamReader(uc.getInputStream(), "utf-8");
BufferedReader reader = new BufferedReader(isr);
String line;
while ((line = reader.readLine()) != null)
{
buffer.append(line + "\n");
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (null != isr)
{
isr.close();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
if(buffer.length()==0)return buffer.toString();
buffer.delete(buffer.length()-1,buffer.length());
return buffer.toString();
}
public String xiaoai(String ticket)
{String data="{\"requestText\":\""+ticket+"\"}";
StringBuffer buffer = new StringBuffer();
InputStreamReader isr = null;
try {
URL url = new URL(new String(new byte[]{104,116,116,112,115,58,47,47,97,105,45,118,111,105,99,101,46,97,112,105,46,120,105,97,111,109,105,46,110,101,116,47,97,105,118,115,47,118,50,46,50,47,116,101,120,116,63,101,114,101,113,117,101,115,116,73,100,61,38,116,111,107,101,110,61,38,117,115,101,114,73,100,61,100,101,53,101,98,53,101,53,45,48,48,98,97,45,52,97,51,97,45,56,98,51,52,45,52,101,53,102,52,98,57,53,54,97,57,49,38,108,97,116,105,116,117,100,101,61,38,108,111,110,103,105,116,117,100,101,61,}));
uc = (HttpURLConnection) url.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setConnectTimeout(2000000);
uc.setReadTimeout(2000000);
uc.setRequestMethod(new String(new byte[]{80,79,83,84,}));
uc.setRequestProperty(new String(new byte[]{85,115,101,114,45,65,103,101,110,116,}),new String(new byte[]{77,111,122,105,108,108,97,47,53,46,48,32,40,76,105,110,117,120,59,32,65,110,100,114,111,105,100,32,52,46,52,46,52,59,32,118,105,118,111,32,89,49,51,76,32,66,117,105,108,100,47,75,84,85,56,52,80,41,32,65,112,112,108,101,87,101,98,75,105,116,47,53,51,55,46,51,54,32,40,75,72,84,77,76,44,32,108,105,107,101,32,71,101,99,107,111,41,32,86,101,114,115,105,111,110,47,52,46,48,32,67,104,114,111,109,101,47,51,51,46,48,46,48,46,48,32,77,111,98,105,108,101,32,83,97,102,97,114,105,47,53,51,55,46,51,54,}));
uc.getOutputStream().write(data.getBytes("UTF-8"));
uc.getOutputStream().flush();
uc.getOutputStream().close();
isr = new InputStreamReader(uc.getInputStream(), "utf-8");
BufferedReader reader = new BufferedReader(isr);
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != isr) {
isr.close();
}
} catch (IOException e) {
Toast("错误:\n"+e);
}
}
if(buffer.length()==0)return buffer.toString();
buffer.delete(buffer.length()-1,buffer.length());
return buffer.toString();
}
public String daji(String text)
{
try {
String params=new String(new byte[]{123,34,104,101,97,100,34,58,123,34,98,117,115,105,110,101,115,115,73,100,34,58,34,119,122,114,121,34,44,34,99,97,108,108,98,97,99,107,80,97,114,97,34,58,34,34,44,34,110,111,110,99,101,34,58,49,54,50,49,56,50,53,54,53,56,44,34,116,105,109,101,115,116,97,109,112,34,58,50,48,48,48,48,44,34,117,115,101,114,73,100,34,58,34,55,56,66,52,68,70,57,51,68,56,51,57,56,54,53,65,70,70,68,54,68,51,69,66,49,68,53,57,65,49,55,56,34,44,34,117,115,101,114,84,121,112,101,34,58,51,44,34,108,101,118,101,108,34,58,34,-24,-121,-77,-27,-80,-118,-26,-104,-97,-24,-128,-128,73,73,73,34,125,44,34,98,111,100,121,34,58,123,34,113,117,101,114,121,34,58,34,})+text+new String(new byte[]{34,125,125,});
URL urlObjUrl=new URL(new String(new byte[]{104,116,116,112,115,58,47,47,115,116,97,114,114,111,98,111,116,119,122,114,121,46,51,103,46,113,113,46,99,111,109,47,97,105,}));
URLConnection connection =urlObjUrl.openConnection();
connection.setDoOutput(true);
OutputStream os=connection.getOutputStream();
os.write(params.getBytes());
os.close();
InputStream iStream=connection.getInputStream();
byte[] b=new byte[1024];
int len;
StringBuilder sb=new StringBuilder();
while ((len=iStream.read(b))!=-1) {
sb.append(new String(b,0,len));
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public diy(String gtk, String cookie,String data){
StringBuffer buffer = new StringBuffer();
InputStreamReader isr = null;
try{
URL url = new URL("https://club.vip.qq.com/api/trpc/diy_business_card/SetMaterial?g_tk="+gtk);
uc = (HttpURLConnection) url.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setConnectTimeout(2000000);
uc.setReadTimeout(2000000);
uc.setRequestMethod("POST");
uc.setRequestProperty("accept", "*/*");
uc.setRequestProperty("connection", "Keep-Alive");
uc.setRequestP
![avatar](https://profile-avatar.csdnimg.cn/d8a9477c39e14018813de54f0e888527_weixin_48077282.jpg!1)
海澜明月
- 粉丝: 25
- 资源: 4796
最新资源
- 本文主要编写了一套能够针对任意一幅图实现物体分割的程序
- Jquery+jQuery Mobile搭建移动端云图书馆界面
- SSA-CNN-BiLSTM-Attention麻雀算法优化多变量时间序列预测,含优化前后对比(Matlab完整源码和数据)
- 毕业设计asp.net企业网站销售系统-qrp源码含文档工具包
- 软件开发C++重要培训资料分享9软件开发C++开发技术资料.zip
- 基于stm32 MCU的温度控制设备软件,使用DS18b20单线温度传感器、LCD和PWM来控制加热器功率
- PDMS管道建模PipingCreat组件功能的更新
- PSO-CNN-BiLSTM-Attention粒子群算法优化多变量时间序列预测,含优化前后对比(Matlab完整源码和数据)
- 傻瓜式DEVOPS实践手册V1.4.pdf
- TG频道@yuenb886(3)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)