How to get page meta (title, description, images) like facebook attach url using Regex in .java
How to get page meta (title, description, images) like facebook attach url using Regex in .java
I use JSOUP to get a Document object, then use something like the below method to get tags for each property I'm looking for.
String findTag(Document document, String property) {
String tag = null;
String cssQuery = "meta[property='og:" + property + "']";
Elements elements = document.select(cssQuery);
if (elements != null && elements.size() >= 1) {
tag = elements.first().attr("content");
}
return tag;
}
I used this often enough to where I decided to combine the fetching (with JSOUP) and parsing together into a library called ogmapper.