- 浏览: 39669 次
- 性别:
- 来自: 深圳
文章分类
最新评论
package org.zlex.commons.net;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Properties;
/**
* 网络工具
*
* @author 梁栋
* @version 1.0
* @since 1.0
*/
public abstract class NetUtils {
public static final String CHARACTER_ENCODING = "UTF-8";
public static final String PATH_SIGN = "/";
public static final String METHOD_POST = "POST";
public static final String METHOD_GET = "GET";
public static final String CONTENT_TYPE = "Content-Type";
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData)
throws Exception {
Properties requestProperties = new Properties();
requestProperties.setProperty(CONTENT_TYPE,
"application/octet-stream; charset=utf-8");
return requestPost(urlString, requestData, requestProperties);
}
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData,
Properties requestProperties) throws Exception {
byte[] responseData = null;
HttpURLConnection con = null;
try {
URL url = new URL(urlString);
con = (HttpURLConnection) url.openConnection();
if ((requestProperties != null) && (requestProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : requestProperties
.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
con.setRequestProperty(key, value);
}
}
con.setRequestMethod(METHOD_POST); // 置为POST方法
con.setDoInput(true); // 开启输入流
con.setDoOutput(true); // 开启输出流
// 如果请求数据不为空,输出该数据。
if (requestData != null) {
DataOutputStream dos = new DataOutputStream(con
.getOutputStream());
dos.write(requestData);
dos.flush();
dos.close();
}
int length = con.getContentLength();
// 如果回复消息长度不为-1,读取该消息。
if (length != -1) {
DataInputStream dis = new DataInputStream(con.getInputStream());
responseData = new byte[length];
dis.readFully(responseData);
dis.close();
}
} catch (Exception e) {
throw e;
} finally {
if (con != null) {
con.disconnect();
con = null;
}
}
return responseData;
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties) throws Exception {
return requestPostForm(urlString, formProperties, null);
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties, Properties requestProperties)
throws Exception {
requestProperties.setProperty(HttpUtils.CONTENT_TYPE,
"application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
if ((formProperties != null) && (formProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : formProperties.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
sb.append(key);
sb.append("=");
sb.append(encode(value));
sb.append("&");
}
}
String str = sb.toString();
str = str.substring(0, (str.length() - 1)); // 截掉末尾字符&
return requestPost(urlString, str.getBytes(CHARACTER_ENCODING),
requestProperties);
}
/**
* url解码
*
* @param str
* @return 解码后的字符串,当异常时返回原始字符串。
*/
public static String decode(String url) {
try {
return URLDecoder.decode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
/**
* url编码
*
* @param str
* @return 编码后的字符串,当异常时返回原始字符串。
*/
public static String encode(String url) {
try {
return URLEncoder.encode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
}
/**
* 2008-12-26
*/
package org.zlex.commons.net;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Properties;
/**
* 网络工具
*
* @author 梁栋
* @version 1.0
* @since 1.0
*/
public abstract class NetUtils {
public static final String CHARACTER_ENCODING = "UTF-8";
public static final String PATH_SIGN = "/";
public static final String METHOD_POST = "POST";
public static final String METHOD_GET = "GET";
public static final String CONTENT_TYPE = "Content-Type";
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData)
throws Exception {
Properties requestProperties = new Properties();
requestProperties.setProperty(CONTENT_TYPE,
"application/octet-stream; charset=utf-8");
return requestPost(urlString, requestData, requestProperties);
}
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData,
Properties requestProperties) throws Exception {
byte[] responseData = null;
HttpURLConnection con = null;
try {
URL url = new URL(urlString);
con = (HttpURLConnection) url.openConnection();
if ((requestProperties != null) && (requestProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : requestProperties
.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
con.setRequestProperty(key, value);
}
}
con.setRequestMethod(METHOD_POST); // 置为POST方法
con.setDoInput(true); // 开启输入流
con.setDoOutput(true); // 开启输出流
// 如果请求数据不为空,输出该数据。
if (requestData != null) {
DataOutputStream dos = new DataOutputStream(con
.getOutputStream());
dos.write(requestData);
dos.flush();
dos.close();
}
int length = con.getContentLength();
// 如果回复消息长度不为-1,读取该消息。
if (length != -1) {
DataInputStream dis = new DataInputStream(con.getInputStream());
responseData = new byte[length];
dis.readFully(responseData);
dis.close();
}
} catch (Exception e) {
throw e;
} finally {
if (con != null) {
con.disconnect();
con = null;
}
}
return responseData;
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties) throws Exception {
return requestPostForm(urlString, formProperties, null);
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties, Properties requestProperties)
throws Exception {
requestProperties.setProperty(HttpUtils.CONTENT_TYPE,
"application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
if ((formProperties != null) && (formProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : formProperties.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
sb.append(key);
sb.append("=");
sb.append(encode(value));
sb.append("&");
}
}
String str = sb.toString();
str = str.substring(0, (str.length() - 1)); // 截掉末尾字符&
return requestPost(urlString, str.getBytes(CHARACTER_ENCODING),
requestProperties);
}
/**
* url解码
*
* @param str
* @return 解码后的字符串,当异常时返回原始字符串。
*/
public static String decode(String url) {
try {
return URLDecoder.decode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
/**
* url编码
*
* @param str
* @return 编码后的字符串,当异常时返回原始字符串。
*/
public static String encode(String url) {
try {
return URLEncoder.encode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
}
注意上述requestPostForm()方法,是用来提交表单的。
测试用例
Java代码
/**
* 2009-8-21
*/
package org.zlex.commons.net;
import static org.junit.Assert.*;
import java.util.Properties;
import org.junit.Test;
/**
* 网络工具测试
*
* @author 梁栋
* @version 1.0
* @since 1.0
*/
public class NetUtilsTest {
/**
* Test method for
* {@link org.zlex.commons.net.NetUtils#requestPost(java.lang.String, byte[])}
* .
*/
@Test
public final void testRequestPostStringByteArray() throws Exception {
Properties requestProperties = new Properties();
// 模拟浏览器信息
requestProperties
.put(
"User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler ; .NET CLR 1.1.4322)");
byte[] b = NetUtils.requestPost("http://localhost:8080/zlex/post.do",
"XML".getBytes());
System.err.println(new String(b, "utf-8"));
}
/**
* Test method for
* {@link org.zlex.commons.net.NetUtils#requestPostForm(java.lang.String, java.util.Properties)}
* .
*/
@Test
public final void testRequestPostForm() throws Exception {
Properties formProperties = new Properties();
formProperties.put("j_username", "Admin");
formProperties.put("j_password", "manage");
byte[] b = NetUtils.requestPostForm(
"http://localhost:8080/zlex/j_spring_security_check",
formProperties);
System.err.println(new String(b, "utf-8"));
}
}
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Properties;
/**
* 网络工具
*
* @author 梁栋
* @version 1.0
* @since 1.0
*/
public abstract class NetUtils {
public static final String CHARACTER_ENCODING = "UTF-8";
public static final String PATH_SIGN = "/";
public static final String METHOD_POST = "POST";
public static final String METHOD_GET = "GET";
public static final String CONTENT_TYPE = "Content-Type";
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData)
throws Exception {
Properties requestProperties = new Properties();
requestProperties.setProperty(CONTENT_TYPE,
"application/octet-stream; charset=utf-8");
return requestPost(urlString, requestData, requestProperties);
}
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData,
Properties requestProperties) throws Exception {
byte[] responseData = null;
HttpURLConnection con = null;
try {
URL url = new URL(urlString);
con = (HttpURLConnection) url.openConnection();
if ((requestProperties != null) && (requestProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : requestProperties
.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
con.setRequestProperty(key, value);
}
}
con.setRequestMethod(METHOD_POST); // 置为POST方法
con.setDoInput(true); // 开启输入流
con.setDoOutput(true); // 开启输出流
// 如果请求数据不为空,输出该数据。
if (requestData != null) {
DataOutputStream dos = new DataOutputStream(con
.getOutputStream());
dos.write(requestData);
dos.flush();
dos.close();
}
int length = con.getContentLength();
// 如果回复消息长度不为-1,读取该消息。
if (length != -1) {
DataInputStream dis = new DataInputStream(con.getInputStream());
responseData = new byte[length];
dis.readFully(responseData);
dis.close();
}
} catch (Exception e) {
throw e;
} finally {
if (con != null) {
con.disconnect();
con = null;
}
}
return responseData;
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties) throws Exception {
return requestPostForm(urlString, formProperties, null);
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties, Properties requestProperties)
throws Exception {
requestProperties.setProperty(HttpUtils.CONTENT_TYPE,
"application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
if ((formProperties != null) && (formProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : formProperties.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
sb.append(key);
sb.append("=");
sb.append(encode(value));
sb.append("&");
}
}
String str = sb.toString();
str = str.substring(0, (str.length() - 1)); // 截掉末尾字符&
return requestPost(urlString, str.getBytes(CHARACTER_ENCODING),
requestProperties);
}
/**
* url解码
*
* @param str
* @return 解码后的字符串,当异常时返回原始字符串。
*/
public static String decode(String url) {
try {
return URLDecoder.decode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
/**
* url编码
*
* @param str
* @return 编码后的字符串,当异常时返回原始字符串。
*/
public static String encode(String url) {
try {
return URLEncoder.encode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
}
/**
* 2008-12-26
*/
package org.zlex.commons.net;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Properties;
/**
* 网络工具
*
* @author 梁栋
* @version 1.0
* @since 1.0
*/
public abstract class NetUtils {
public static final String CHARACTER_ENCODING = "UTF-8";
public static final String PATH_SIGN = "/";
public static final String METHOD_POST = "POST";
public static final String METHOD_GET = "GET";
public static final String CONTENT_TYPE = "Content-Type";
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData)
throws Exception {
Properties requestProperties = new Properties();
requestProperties.setProperty(CONTENT_TYPE,
"application/octet-stream; charset=utf-8");
return requestPost(urlString, requestData, requestProperties);
}
/**
* 以POST方式向指定地址发送数据包请求,并取得返回的数据包
*
* @param urlString
* @param requestData
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPost(String urlString, byte[] requestData,
Properties requestProperties) throws Exception {
byte[] responseData = null;
HttpURLConnection con = null;
try {
URL url = new URL(urlString);
con = (HttpURLConnection) url.openConnection();
if ((requestProperties != null) && (requestProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : requestProperties
.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
con.setRequestProperty(key, value);
}
}
con.setRequestMethod(METHOD_POST); // 置为POST方法
con.setDoInput(true); // 开启输入流
con.setDoOutput(true); // 开启输出流
// 如果请求数据不为空,输出该数据。
if (requestData != null) {
DataOutputStream dos = new DataOutputStream(con
.getOutputStream());
dos.write(requestData);
dos.flush();
dos.close();
}
int length = con.getContentLength();
// 如果回复消息长度不为-1,读取该消息。
if (length != -1) {
DataInputStream dis = new DataInputStream(con.getInputStream());
responseData = new byte[length];
dis.readFully(responseData);
dis.close();
}
} catch (Exception e) {
throw e;
} finally {
if (con != null) {
con.disconnect();
con = null;
}
}
return responseData;
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties) throws Exception {
return requestPostForm(urlString, formProperties, null);
}
/**
* 以POST方式向指定地址提交表单<br>
* arg0=urlencode(value0)&arg1=urlencode(value1)
*
* @param urlString
* @param formProperties
* @param requestProperties
* @return 返回数据包
* @throws Exception
*/
public static byte[] requestPostForm(String urlString,
Properties formProperties, Properties requestProperties)
throws Exception {
requestProperties.setProperty(HttpUtils.CONTENT_TYPE,
"application/x-www-form-urlencoded");
StringBuilder sb = new StringBuilder();
if ((formProperties != null) && (formProperties.size() > 0)) {
for (Map.Entry<Object, Object> entry : formProperties.entrySet()) {
String key = String.valueOf(entry.getKey());
String value = String.valueOf(entry.getValue());
sb.append(key);
sb.append("=");
sb.append(encode(value));
sb.append("&");
}
}
String str = sb.toString();
str = str.substring(0, (str.length() - 1)); // 截掉末尾字符&
return requestPost(urlString, str.getBytes(CHARACTER_ENCODING),
requestProperties);
}
/**
* url解码
*
* @param str
* @return 解码后的字符串,当异常时返回原始字符串。
*/
public static String decode(String url) {
try {
return URLDecoder.decode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
/**
* url编码
*
* @param str
* @return 编码后的字符串,当异常时返回原始字符串。
*/
public static String encode(String url) {
try {
return URLEncoder.encode(url, CHARACTER_ENCODING);
} catch (UnsupportedEncodingException ex) {
return url;
}
}
}
注意上述requestPostForm()方法,是用来提交表单的。
测试用例
Java代码
/**
* 2009-8-21
*/
package org.zlex.commons.net;
import static org.junit.Assert.*;
import java.util.Properties;
import org.junit.Test;
/**
* 网络工具测试
*
* @author 梁栋
* @version 1.0
* @since 1.0
*/
public class NetUtilsTest {
/**
* Test method for
* {@link org.zlex.commons.net.NetUtils#requestPost(java.lang.String, byte[])}
* .
*/
@Test
public final void testRequestPostStringByteArray() throws Exception {
Properties requestProperties = new Properties();
// 模拟浏览器信息
requestProperties
.put(
"User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler ; .NET CLR 1.1.4322)");
byte[] b = NetUtils.requestPost("http://localhost:8080/zlex/post.do",
"XML".getBytes());
System.err.println(new String(b, "utf-8"));
}
/**
* Test method for
* {@link org.zlex.commons.net.NetUtils#requestPostForm(java.lang.String, java.util.Properties)}
* .
*/
@Test
public final void testRequestPostForm() throws Exception {
Properties formProperties = new Properties();
formProperties.put("j_username", "Admin");
formProperties.put("j_password", "manage");
byte[] b = NetUtils.requestPostForm(
"http://localhost:8080/zlex/j_spring_security_check",
formProperties);
System.err.println(new String(b, "utf-8"));
}
}
发表评论
文章已被作者锁定,不允许评论。
相关推荐
《Http请求模拟报文返回工具详解》 在IT行业中,Http请求模拟报文返回工具扮演着重要的角色。它允许开发者和测试人员在不依赖实际服务器的情况下,模拟HTTP响应,进行功能验证、性能测试或者异常情况的模拟。这种...
HTTP请求模拟允许开发者在代码中复现浏览器与服务器间的通信过程,以发送GET、POST等不同类型的请求。本文将深入探讨如何在C#中实现HTTP请求模拟,并以`TestHttpPost`为例,讲解POST请求的实现。 首先,让我们了解...
本文将详细介绍两个流行的HTTP请求模拟工具——HTTPDebug和WFetch,它们可以帮助开发者更好地理解和操作HTTP协议,进行各种网络请求测试。 **HTTPDebug** HTTPDebug是一款功能强大的HTTP请求模拟工具,它允许用户...
Restclient是一款强大的HTTP请求模拟工具,它专为开发者设计,用于测试和调试RESTful API接口。这个工具允许用户发送各种类型的HTTP请求,如GET、POST、PUT、DELETE等,并能够自定义请求头(headers)和请求体(body...
Postman是一款强大的网络请求模拟工具,尤其在mac环境下,它为开发者提供了便利的API测试与调试功能。Postman不仅能够发送各种HTTP请求,如GET、POST、PUT等,还支持设置请求头、查询参数、请求体,以及处理响应数据...
在本场景中,"多线程客户端请求模拟"是指客户端程序利用多线程技术来并发地向服务器发送请求,以测试或模拟实际网络环境中的高并发情况。这种方式可以更真实地反映出服务器在大量并发请求下的性能表现,帮助开发者...
POSTMAN请求模拟工具是一款强大的API测试与开发辅助工具,它极大地简化了网络请求的创建、发送和测试过程。无论你是开发者、测试工程师还是对API有需求的用户,Postman都能帮助你高效地进行HTTP请求的模拟,理解并...
请求模拟 js本地运行
Postman是一款强大的API开发、测试和文档工具,它作为一个Chrome浏览器插件被广泛使用,能够帮助开发者模拟多种客户端请求,从而实现对Web服务接口的测试和调试。在本文中,我们将深入探讨Postman的功能、使用方法...
在这个场景中,我们探讨的主题是如何利用HTML页面来模拟GET和POST请求,尤其是处理POST请求时如何以JSON(JavaScript Object Notation)格式传递参数。这在前端开发、网页表单提交以及API测试中是非常常见且重要的...
总之,HttpDebug是一款高效且易用的HTTP请求模拟工具,无论你是初学者还是经验丰富的开发者,都能从中受益,提升你的开发和调试效率。通过深入理解和熟练运用HttpDebug,你可以更好地理解网络通信过程,排查和修复...
1. **请求模拟**: - GET请求:用于获取资源,Postman可以方便地构造GET请求,获取服务器上的数据。 - POST请求:通常用于向服务器发送数据,创建新的资源。在Postman中,用户可以填写请求体,设置Content-Type,...
工具小巧
网络请求模拟器,可以自定义Header内容,以及多种格式参数的访问
改资源中携带报文模拟范例,亲测有效。注释详细,步骤突出!源于真实需求,工具类拿来急用,具体业务可以稍调一下
**Postman:强大的HTTP请求模拟工具** Postman是一款在IT行业中广泛应用的网页调试工具,尤其在Web开发、API测试和集成过程中,它扮演着至关重要的角色。作为一个专业的Chrome插件,Postman允许开发者轻松地发送...
httppost可以模拟post发送和get方法向目标网站提交请求,这个是电脑端的软件,不是运行于web的脚本代码 1. testhttppost.exe:http post上传文件工具; 2. TestHttpPost: 源码; 3.lr_post.txt: 录制的loadrunner ...
网络爬虫是一种自动浏览和抓取网页的程序,它通常会利用HTTP/HTTPS请求模拟登录到网站,以便抓取需要的数据。在实现过程中,socket可以用于创建自定义的HTTP客户端,绕过一些常规的HTTP库限制,实现更灵活的网络交互...
一个简单的在线模拟HTTP请求模拟解决方案 基本网址 https://mok.now.sh/ 请求示例: wget -q -O - " $@ " " mok.now.sh/?response={ \" hello \" : \" world \" }&responseType=json " 路径 您可以使用任何喜欢的...