2011-08-12 13 views
1

私はウェブサイト(http://wowhead.com)からいくつかの情報を取得しようとしていますが、HTMLのアジリティパックでは十分ですが、Javaスクリプトタグの後にどのように情報を取得するのかが不安です。javascriptのテキストからの情報

から情報を取得しようとして何イムソースは、すべてのことから、今

<script type="text/javascript">//<![CDATA[ 
Markup.printHtml("[ul][li]Level: 49[/li][li]Requires level 47[/li][li]Loremaster:   [url=/achievement=4931]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] &nbsp;[/small][color=r3]52[/color][small] &nbsp;[/small][color=r4]59[/color][/li][li]Added in patch 4.0.3[/li][/ul]", "sdhafcuvh0", { allow: Markup.CLASS_STAFF, dbpage: true }); 
//]]></script> 

あり、中にイム興味が唯一のものは、私だけ表示を行いたいから

[url=/npc=48127]Darla Drilldozer[/url] 

からの情報です48127とDarla Drilldozer。

どうすればよいですか?ここで

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(); 
    } 
} 

}

後だから、クエストの贈り主とクエスト寄贈者のIDに必要な情報は、上記からあるものイムの種類を示すために、コンソールでの私の現在のコードの例です。 Javascript。

この情報を入手する方法はありますか?

+0

+1おはようございます!正規表現でこれを簡単にすることができると思います。 –

答えて

0

猫をスキンする方法はたくさんあります。この場合は、探している単語の位置を見つけて、単純なstring.substringを使用することです。それはあなたのために働くだろうか?

+0

返信のための乾杯。私はC#の新機能としてこれを使ってプロジェクトを作成しています。これはちょっとしたことです(私のプロジェクトではコンソールアプリケーションを心配しないでください:p)それは私にとってはうまく説明できるチュートリアルですか? – neoDite

関連する問題