json - How to get webcam video file url from Weather Underground response in Android using JSOUP? -
i able play webcam video response in video view json response weather underground "camurl" so:
the url video need play embedded in html code url so:
https://www.wunderground.com/webcams/cadot1/1216/video.html?month=11&year=2016&filename=current.mp4
is there way url json response "camurl"? i've heard of term "html scraping", possible embedded video url json response html page?
this full json response looks webcam:
{ "handle": "mahouser", "camid": "mahousercam1", "camindex": "1", "assoc_station_id": "kcacamar18", "link": "http://", "linktext": "michael houser", "cameratype": "foscam fi9900p", "organization": "", "neighborhood": "camarillo hills", "zip": "93010-12", "city": "camarillo", "state": "ca", "country": "us", "tzname": "america/los_angeles", "lat": "34.24947357", "lon": "-119.03993988", "updated": "2016-11-10 20:57:24", "updated_epoch": "", "downloaded": "2016-11-08 20:38:48", "isrecent": "1", "currentimageurl": "http://icons.wunderground.com/webcamramdisk/m/a/mahouser/1/current.jpg?t=1478812080", "widgetcurrentimageurl": "http://icons.wunderground.com/webcamramdisk/m/a/mahouser/1/widget.jpg?t=1478812080", "camurl": "http://www.wunderground.com/webcams/mahouser/1/show.html" } i've looked @ jsoup , read documentation can't figure out how needed url. here how url looks in html:
<td class="day"> <div class="row"> <div class="small-2 medium-5 columns"> <a href="/history/airport/kajo/2016/11/15/dailyhistory.html" class="day-num"> 15 </a> </div> <div class="small-10 medium-7 columns"> <img src="//icons.wxug.com/i/c/v4/clear.svg" alt="clear" class="right" /> </div> </div> <div class="calthumb"> <a href="http://icons.wunderground.com/webcamramdisk/c/a/cadot1/902/current.jpg?1479239986" rel="lightbox[webcam]" title=""> <img src="http://icons.wunderground.com/webcamramdisk/c/a/cadot1/902/current-thumb.jpg?1479239986" width="100" height="75" alt="" title="click view time-lapse video day." /> </a> </div> <p><a href="video.html?month=11&year=2016&filename=current.mp4" class="videotext">view video</a></p> </td> how can "current.mp4" url within html code?
there lot of possible ways, here simple solution:
-
document doc = jsoup.connect("http://www.wunderground.com/webcams/cadot1/902/show.html").get(); then, retrieve elements class videotext:
elements elements = doc.getelementsbyclass("videotext");this give list of entries. select 1 ends current.mp4.
to retrieve current.mp4 url:
for (element link : elements) { string linkhref = link.attr("href"); // linkhref contains video.html?month=11&year=2016&filename=current.mp4 // todo check if linkhref ends current.mp4 }
Comments
Post a Comment