How to submit text via forms using JSoup
15,449
Solution 1
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.
Solution 2
jSoup
Elements txtArea = doc.select("#quickpost");
txtArea.text(yourText);
jQuery
$('#quickpost').val(yourText);
Author by
Gwindow
Updated on June 25, 2022Comments
-
Gwindow about 2 years
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>
-
Gwindow almost 13 yearsHow would I go about posting it back to the site?
-
citizen conn almost 13 yearsjSoup is for scraping and parsing HTML, not really for modifying display. For that you would use jQuery on the client side. See my edited answer.
-
Gwindow almost 13 yearsanyway to do it with jSoup rather than jQuery?
-
Gwindow almost 13 yearsI'm not sure how to answer that question.
-
citizen conn almost 13 yearsWhat are you using to show web pages to the user? Java is a server-side technology.
-
Gwindow almost 13 yearsI'm writing an android app, I'm parsing page sources from a site using JSoup, and displaying certain parts.