html - C# Getting Text from object in web page -
i'm trying recreate old c# application of mine streams online radio station. problem old 1 is, loaded entire web page display area of it, takes more resources deem necessary. so, i'm rewriting entire application, , looking way how can retrieve text following code on website:
<div id="now" style="visibility: visible; display: block;"> <div class="scroll" style="margin-left: 0.000px;"> <div id="title">song_name</div> <div id="artist">song_artist</div> </div> </div>
this piece updated on page, name , artist of current song.
id="title" name of song , id="artist" artist of song.
i retrieve name , artist every say, 10 seconds or so.
any idea code use ?
you'll want pull entire page back. main considerations are:
- you request html uncompressed , open stream using
httpwebresponse.getresponsestream
, read until end of block need (you'll need analyse text go), , callhttpwebresponse.close
close stream , release connection - if entire response compressed may more efficient whole thing anyway before decompressing.
you need test more efficient specific page scraping.
so usual way retrieve whole html stream, use regex find block need, , keep code simple.
recommendation
if want keep really simple @ htmlagilitypack, on nuget use visual studio 2012. makes working html scraping simple.
Comments
Post a Comment