Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Unable to get the html content of a page, which contains data from external api

Level 2
Level 2



When I am trying to access the html content of a page using jsoup, I am unable to get the content which is referring form api. Can someone help me in getting the content, which is coming from external api, in java.


Thanks in advance.

1 Reply
Community Advisor
Community Advisor

Hi @himasreep445197 


Lets say you have input stream of the page getting from external api, then using below code snippet we will be able access page content, elements & iterate through the elements.


InputStream inputStream; //fetch from external api;
String htmlContent = IOUtils.toString(inputStream);
Document document = Jsoup.parse(htmlContent);
Elements imageElements = document.getElementsByTag("img");
Elements metaElements = document.getElementsByTag("meta");
Elements headElement = document.getElementsByTag("head");
Elements scriptElements = document.getElementsByTag("script");

scriptElement ->
String scriptPath = scriptElement.attr("src");