How to get the image URL from html code using Java -
this question has answer here:
- which html parser best? [closed] 3 answers
given sample html below. how can image link http://lis.deped.gov.ph/uis/assets/rev/2630813/images/deped-logo.gif? in case image link starts in
//like
//uis/assets/rev/2630813/images/deped-logo.gif` have add string before it.
how regex? not want use http library.
<div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#deped-uis-nav-collapse"><span class="sr-only">toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><span class="navbar-brand"><img class="logo" src="http://lis.deped.gov.ph/uis/assets/rev/2630813/images/deped-logo.gif" alt="deped" style="height: 20px; margin-top: -2px"></span></div>
you can use jsoup this..
refer below code.. need add jsoup library make work.
string html = "<html>your html code goes here</html>"; document doc = jsoup.parse(html); elements image = doc.getelementsbytag("img"); (element el : image) { string src = el.absurl("src"); system.out.println("src attribute : "+src); }
Comments
Post a Comment