HTML页面看起来像这样提取特定文本
<tr>
<th rowspan="4" scope="row">General</th>
<td class="ttl"><a href="network-bands.php3">2G Network</a></td>
<td class="nfo">GSM 850/900/1800/1900 </td>
</tr><tr>
<td class="ttl"><a href="network-bands.php3">3G Network</a></td>
<td class="nfo">HSDPA 900/1900/2100 </td>
</tr>
对此,我尝试使用
var text = document.getElementsByClassName("nfo")[0].innerHTML;
提供由亚历克斯
但我得到这个错误 错误2名称'document'在当前上下文中不存在C:\ Users \ Nabi Javid \ Documents \ Visual Studio 2008 \ Projects \ WpfApplication2 \ WpfApplication2 \ Window1.xaml.cs 30 22 WpfApplication2
我失去了一些Libary什么
目前我的代码就是这样
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.Load("nokia_c5_03-3578.html");
var text = document.getElementsByClassName("nfo")[0].innerHTML;
}
}
}
28:9他认为他的使用HAP,但他写的JavaScript。 – SLaks 2010-11-19 15:01:39
@SLaks - 重读这个,你是对的。 – Oded 2010-11-19 15:02:03
无论谁投降,请与我们分享您的知识。 – acme 2012-09-17 15:26:08