Vb スクリプトを使用して HTML ページから情報を抽出しようとしています。これは、情報を抽出しようとしている HTML ページです。
<div id="profile-education">
<div class="position first education vevent vcard" id="xxxxxx">
University 1
<span class="degree">Ph.D.</span>
<span class="major">Computer Science</span>
<p class="period">
<abbr class="dtstart" title="2005-01-01">2005</abbr> – <abbr class="dtend"
title="2012-12-31">2012</abbr>
</div>
<div class="position education vevent vcard" id="xxxxxx">
University 2
<span class="degree">M.Eng.</span>
<span class="major">Computer Science</span>
<p class="period">
<abbr class="dtstart" title="2000-01-01">2000</abbr> – <abbr class="dtend"
title="2004-12-31">2004</abbr>
</p>
</div>
</div>
以下の形式で情報を抽出したいと思います。
- 大学名:第一大学
- 学位名: Phd
- 専攻:コンピュータサイエンス
期間:2005年~2012年
大学名:第二大学
- 学位名: M.Eng
- 専攻:コンピュータサイエンス
- 期間:2000年~2004年
私の VB スクリプトには、情報全体を 1 つの変数として抽出する次のコードがあります。
Dim openedpage as String
openedpage = iedoc1.getElementById("profile-education").innerText
ただし、vb スクリプトで次のステートメントを使用すると、特定のスパン情報を取得できます。
openedpage = iedoc1.getElementById("profile-education").getElementsByTagName("span")
(0).innerText
上記のコードは、出力として Phd を提供します。ただし、事前に合計スパンがわからないため、コードで単にスパン(0)とスパン(1)を指定することはできません。また、すべての div タグの情報を抽出したいのですが、この情報もわかりません。基本的に、複数の div およびスパン情報を抽出できるようにする必要がある id profile-educationを使用して、div タグを反復処理するループ構造が必要です。