Created
July 28, 2016 03:04
-
-
Save chowaikong/a45d1009aa0063f13e5f888b01571b2b to your computer and use it in GitHub Desktop.
Jsoup Get Metadata From HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
public class JsoupGetMetaData { | |
public static void main(String args[]){ | |
Document document; | |
String html = ""; | |
try { | |
document = Jsoup.connect(html).get(); | |
// both method below are working | |
String xx = | |
document.select("meta[name=xx]").get(0).attr("content"); // xx: your desire meta property | |
String xxx = | |
document.select("meta[name=xxx]").first().attr("content"); //xxx: your desire meta property | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment