I am trying to use jsoup in my android studio project but i keep getting this error: Error:(10, 16) Gradle: error: package org.jsoup does not exist.
Could you guys tell me the steps on how to add jsoup library to my project? Thanks in advance.
Edit: For learning purpuse i am running the java code alone without main activity!
code:
package com.jsoupTest.jsoupTest;
import java.io.IOException;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.UnsupportedMimeTypeException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
public class JsoupGetRequest {
public static void main(String[] args) throws IOException {
String dc=Jsoup.connect("http://somelink.com").timeout(6000).get();
System.out.println(dc);
}
}
jsoup is a Java library for working with real-world HTML. It provides a very convenient API for fetching URLs and extracting and manipulating data, using the best of HTML5 DOM methods and CSS selectors. jsoup implements the WHATWG HTML5 specification, and parses HTML to the same DOM as modern browsers do.
If you use Eclipse…Right click on the project (ctrl+enter) and select “Java Build Path” from the sidebar and then “Libraries” from the top bar. Finally, choose “Add External JARs…” and import the Jsoup JAR file.
jsoup can parse HTML files, input streams, URLs, or even strings. It eases data extraction from HTML by offering Document Object Model (DOM) traversal methods and CSS and jQuery-like selectors. jsoup can manipulate the content: the HTML element itself, its attributes, or its text.
Gradle (build.gradle) in your app folder. put under dependencies section. clean and rebuild project
// jsoup HTML parser library @ https://jsoup.org/
implementation 'org.jsoup:jsoup:1.10.3'
You should add your dependencies in your build.gradle file. Please check the screenshot attached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With