Allow user to change JSOUP URL

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Allow user to change JSOUP URL



My goal is to give the user the ability to change the end of a URL based on information entered by the user.



Here is the code I have for the JSOUP.


private void getWebsite()
new Thread(new Runnable()
@Override
public void run()
final StringBuilder builder = new StringBuilder();
final StringBuilder builder2 = new StringBuilder();
final StringBuilder builder3 = new StringBuilder();

try
Document doc = Jsoup.connect("www.randomurl.com").get();
Elements links = doc.select("div1");
Elements links2 = doc.select("div2");
Elements links3 = doc.select("div3");

for (Element link : links)
builder.append("n").append(link.text());
builder2.append("n").append(links2.text());
builder3.append("n").append(links3.text());


catch (IOException e)
builder.append("Error : ").append(e.getMessage()).append("n");


runOnUiThread(new Runnable()
@Override
public void run()
result.setText(builder.toString());
worth.setText(builder2.toString());
price.setText(builder3.toString());

);

).start();



My goal is to have a box where a user can enter in information and this is applied to the last part of the URL. For example like this.


try {
Document doc = Jsoup.connect("www.randomurl.com/" + *userEnteredStringHere*).get();



Any insight on how to complete this would be awesome!



EDIT :-


@Override
public void run() {
final StringBuilder builder = new StringBuilder();
final StringBuilder builder2 = new StringBuilder();
final StringBuilder builder3 = new StringBuilder();
EditText userInput = findViewById(R.id.userInputWidget);

try {
Document doc = Jsoup.connect("www.randomurl.com" + userInput.getText()).get();




1 Answer
1



It's not really a Jsoup question.
I bet your app has some GUI which is layout defined as xml file.
It should contain EditText widget so user will be able to input text:


EditText


<EditText
android:id="@+id/userInputWidget"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:inputType="text"/>



Then you can access it in your code:


EditText userInput = (EditText) findViewById(R.id.userInputWidget);
userInput.getText();





This actually somewhat worked. Thanks!! I updated my question to show it with your answer.
– Maxwell Runion
Aug 12 at 2:49






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered