我要做的是解析加载到网页浏览器的网页中的某些文字。更具体地说,这行代码。
<span class="price" id="selecttrainform1_addToCartPrice">$20.00</span>
它位于1342行。如果有帮助,这就是它之前的所有代码,它们位于同一条线上。
<nobr><input type="image" onclick="return onAddToCartClick('selecttrainform', '1', '');" src="/images/en/avs_addtocart_gray.gif" alt="Add To cart >" border="0" name="_handler=presentation.handler.request.rail.RailSimpleSelectDepartAvailabilityRequestHandler/_xpath=/sessionWorkflow/productWorkflow[@product='Rail']/tripJourneyTariffAvailability/journeyTariffAvailability[1]/binding[1]/journey/segment[1]/_/sessionWorkflow/productWorkflow[@product='Rail']/selectedJourney/@id_=_hy0s6wf8a3gi" /><span class="price" id="selecttrainform1_addToCartPrice">$20.00</span>
我正在尝试用这个价格做一个消息框显示它。我可以有三个不同的msgbox,来自三个不同的webbrowsers,或只有一个msgbox从三个显示。这对我来说没什么大不了的。同样,这段代码只会放在一个按钮中。当然,如果需要,我可以将信息显示在文本框而不是msgbox中。我更喜欢msgbox。
我以为我可以使用像
这样的东西 If webpageelement3.GetAttribute("id") = "selecttrainform1_addToCartPrice" Then
MsgBox("the price data here")
但是我不确定如何让它显示在消息框中。上面的代码是我以前查找的一部分,单击一个按钮,只是省略了webpagelement.invokemember(“click”)命令。
有没有人知道任何有用的资源或链接?我试过通过谷歌搜索,但目前还没有结果。
这是通过vb.net进行的。
答案 0 :(得分:0)
如果网络浏览器需要以某种方式进行视觉反馈:
Dim price As String = WebBrowser1.Document.GetElementById("selecttrainform1_addToCartPrice").InnerText
MessageBox.Show(price)
如果它们只是下载网页的一种方式,那么我建议删除它们并使用HtmlAgilityPack或CSQuery之类的东西