|
楼主 |
发表于 2014-12-27 17:04:17
|
显示全部楼层
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
txtUrl.Text = "http://www.daodao.com/Hotel_Review-g297446-d651294-Reviews-or30-Galactic_Peace_International_Hotel-Nanchang_Jiangxi.html";
wbrr1.Navigate(txtUrl.Text);
}
private void btnRedirect_Click(object sender, EventArgs e)
{
wbrr1.Navigate(txtUrl.Text);
}
private void button1_Click(object sender, EventArgs e)
{
HtmlElementCollection elmts = wbrr1.Document.GetElementsByTagName("span");
foreach (HtmlElement elmt1 in elmts)
{
if (Regex.IsMatch(elmt1.OuterHtml, "'review_48438299',"))
{
MessageBox.Show("找到第1个‘更多’的span,outerhtml为\r\n" + elmt1.OuterHtml);
break;
}
}
}
}
这是代码,可以找到标签提示出来outerhtml是:
<SPAN class=partnerRvw onclick="_gaq = _gaq || [];_gaq.push(['_trackEvent', 'Expand User Review','Click']);"><SPAN class="taLnk hvrIE6 tr48438299 moreLink" onclick="ta.util.cookie.setPIDCookie(2247);ta.call('ta.servlet.Reviews.expandReviews',event,this,'review_48438299', '1')">更多 </SPAN><IMG class="textArrow_more sprite-text_arrow_dropdown_blu" alt="" src="http://cc1.ddcdn.com/img2/x.gif"> </SPAN> |
|