我正在研究如何抓取信息.关于http客户端如何与jsoup相关,我有点困惑.你需要http客户端使用jsoup,还是jsoup可以替换http客户端?如果你仍然需要http客户端,它执行的功能是什么,jsoup不能自己做?
下午好,
通常,我需要通过JSOUP以响应multipart/form-data的形式将数据发送到站点
例如,采用sgeniriruet您的查询的简单形式.
<form action =« localhost:8000 »method =«post»enctype =«multipart/form-data»
<input type =«text»name =«text»value =«text default»
<input type =«file»name = «file1»
<input type =«file»name =«file2»
Submit </ button
</ form
通过浏览器发布回复:
>Request Headers Provisional headers are shown Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Content-Type:multipart/form-data;
boundary=----WebKitFormBoundaryjtkXVNw9YVG1H2P9 Origin:null
Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106
Safari/537.36
X-DevTools-Emulate-Network-Conditions-Client-Id:8DCCE949-56FA-4AB0-81B7-DA2BC7960E5C
->Request Payload
------WebKitFormBoundaryjtkXVNw9YVG1H2P9 Content-Disposition: form-data; name=«text»
text default
------WebKitFormBoundaryjtkXVNw9YVG1H2P9 Content-Disposition: form-data; name=«file1»; filename="" Content-Type:
application/octet-stream
------WebKitFormBoundaryjtkXVNw9YVG1H2P9 Content-Disposition: form-data; name=«file2»; filename="" Content-Type:
application/octet-stream
------WebKitFormBoundaryjtkXVNw9YVG1H2P9--
Run Code Online (Sandbox Code Playgroud)
我试图创建一个类似的请求,但没有找到正确的方法,以便服务器收到请求.
我的代码:
Map<String, …Run Code Online (Sandbox Code Playgroud)