开发者

How to submit text via forms using JSoup

I'd like to submit some text into this form using JSoup. How would I go about doing this?

<form id="quickpostform" action="" method="post" style="display: block; text-align: center; ">
<input type="hidden" name="action" value="reply"/>
<input type="hidden" name="auth" value="54a9871a63a1c285879a5327faf3d8d2"/>
<input type="hidden" name="thread" value="135454"/>
<div id="quickreplytext">
<textarea id="quickpost" style开发者_开发百科="width: 95%; " tabindex="1" onkeyup="resize('quickpost');" name="body" cols="90" rows="8"/>
<br/>
</div>


Take a look at the jsoup.connect method and the Connection interface.

Once you have the text you want to submit ready to go, you can post it to a URL as a form submission.

E.g.:

Document doc = Jsoup.connect(url)
    .data("action", "reply")
    .data("auth", "54a9871a63a1c285879a5327faf3d8d2")
    .data("thread", "135454")
    .data("quickreplytext", replyText)
    .post();

The returned doc object will be the result page of the post.


jSoup

Elements txtArea = doc.select("#quickpost");
txtArea.text(yourText);

JSoup Documentation

jQuery

$('#quickpost').val(yourText);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜