im trying to get some information from a website (http://wowhead.com) now most if it is easy enough with html agility pack, but im stuck on how to get information after a java script tag.
The source what im trying to get info from is
<script type="text/javascript">//<![CDATA[
Markup.printHtml("[ul][li]Level: 49[/li][li]Requires level 47[/li][li]Loremaster: [url=/achievement=4开发者_开发问答931]Felwood[/url][/li][li]Side: [span class=icon-horde]Horde[/span][/li] [li][icon name=quest_start]Start: [url=/npc=48127]Darla Drilldozer[/url][/icon][/li][li] [icon name=quest_end]End: [url=/npc=48127]Darla Drilldozer[/url][/icon][/li] [li]Sharable[/li][li]Difficulty: [color=r2]47[/color][small] [/small][color=r3]52[/color][small] [/small][color=r4]59[/color][/li][li]Added in patch 4.0.3[/li][/ul]", "sdhafcuvh0", { allow: Markup.CLASS_STAFF, dbpage: true });
//]]></script>
Now from all that, the only thing im interested in is the info from
[url=/npc=48127]Darla Drilldozer[/url]
From which i only want do display 48127 and Darla Drilldozer.
Is there anyway to do this?
Here is an example of my current code in a console to show what kind of thing im after
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using HtmlAgilityPack;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Enter the Quest ID and set it as a WoWHead link
Console.WriteLine("Enter quest ID");
string ID = Console.ReadLine();
Console.WriteLine("Gathering Quest information from: http://www.wowhead.com/quest=" + ID);
//Load WoWHead and search for the quest name in <h1>
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load("http://wowhead.com/quest=" + ID);
HtmlNodeCollection Qname = doc.DocumentNode.SelectNodes("//h1");
//Set QuestName as the second <h1> tag
string QuestName = (Qname[1].InnerText);
//Display information recivied
Console.WriteLine("Quest ID: " + ID);
Console.WriteLine("Quest Name: " + QuestName);
Console.WriteLine("Quest Giver: " );
Console.WriteLine("Quest Giver ID: ");
Console.ReadLine();
}
}
}
So the information needed for Quest giver and Quest giver ID are from the above Javascript.
Is there any way to get this information?
There are many ways to skin a cat, and one of them in this case, is to find the position of the word you are looking for and use a simple string.substring. would that work for you?
精彩评论