Pull timer value from a webpage using xPath and C# -


i trying pull timer values off of websites using xpath in htmlagilitypack. however, when using xpath, null reference exceptions because particular node not exist when grabbing it. test why was, used doc.save check nodes myself, , found nodes not exist. understanding, htmlagilitypack should download webpage how see it, data in there well. however, of data in fact missing.

how supposed grab timer values, or event title either of following websites:

http://dulfy.net/2014/04/23/event-timer/

http://guildwarstemple.com/dragontimer/eventsb.php?serverkey=108&langkey=1

my current code pull title of event first timebox guildwarstemple is:

public void updateeventdata() {     //string url = "http://dulfy.net/2014/04/23/event-timer/";     string url = "http://guildwarstemple.com/dragontimer/eventsb.php?serverkey=108&langkey=1";     htmlweb web = new htmlweb();     htmldocument doc = web.load(url);      doc.save("c:/doc.html");     title = doc.documentnode.selectnodes("//*[@id='ep1']/p")[0].innertext;     //*[@id="schedulelist"]/div[3]     //*[@id="schedulelist"]/div[3]/div[3]/text() } 

you xpath expression fails because there one div @id='ep1' in document, , has no p inside:

<div id="ep1" class="eventtimebox"></div> 

in fact, all divs in megacontainer empty in link trying load code.

if think there should p elements in there, it's being added dynamically via javascript, might not available when scraping site c# client.

in fact, there javascript variables:

<script> ... var e7 = 'ep1'; ... var e7t = '57600'; ... 

maybe want data. this:

substring-before(substring-after(normalize-space(//script[contains(.,"var e7t")]),"var e7t = '"),"'") 

selects <script> contains var e7t , extracts string in apostrophes. return:

57600 

the same other link. expression:

//*[@id="schedulelist"] 

is empty div. can't navigate further inside it:

<div id="schedulelist" style="width: 720px; min-width: 720px; background: #1a1717; color: #656565;"></div> 

but time there seems no nested javascript refers in page.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -