JSoup is usually used to write network ants. Below is an example of using JSoup to submit a form.
<?xml version='1.0' encoding='utf-8'?>
<Document name="FormSubmit" descriptors="xworker.jsoup.DocumentActions/@Document" url="https://www.xworker.org/do?sc=xworker.example.web.login.LoginExample" >
<description><![CDATA[<p>First grab the login page, then fill in the username and password and submit, and finally output the interface returned after the form is submitted in the log. </p>
]]></description>
<AllElements>
<Forms>
<Iterator>
<Groovy name="setFormValue">
<code><![CDATA[import xworker.lang.executor.Executor;
def TAG = "FormSubmit";
for(element in form.elements()){
if(element.attr("name") == "name"){
element.val("admin");
}else if(element.attr("name") == "password"){
element.val("admin");
}
Executor.info(TAG, element.attr("name") + "=" + element.val());
}]]></code>
</Groovy>
<Submit>
<Post>
<RunAction>
<ExecutorLog name="log" descriptors="xworker.lang.executor.ExecutorActions/@Log"
executorService="var:executorService" tag="FormSubmit"
message="template:The form has been submitted: ${document?string}"/>
</RunAction>
</Post>
</Submit>
</Iterator>
</Forms>
</AllElements>
</Document>
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号