Web抓取C#无法获取页面源中的数据 [英] Web scraping C# not able to get data in page source

查看:88
本文介绍了Web抓取C#无法获取页面源中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网站上显示的数据的Xpath是:// * [@ id =price]。

HTML行是: 15.25



当尝试查看页面源时,值15.25未显示。 />
这是页面来源: -



...

Xpath of data displayed in website is : "//*[@id="price"]".
HTML line is : "15.25".

When try to view page source the value 15.25 is not showing.
Here is the piece of page source: -

...

<td colspan="2" style="text-align:center">
									<span id="price" style=" font-size: 1.8em;font-weight: bold;line-height: 20px;"></span>
									<span id="vxRate"></span>
								</td>



...


...

<script>fetchPrice();</script>
<script>fetchvRate();</script>





我的尝试:



HtmlAgility包以及来自互联网的几种方法。



What I have tried:

HtmlAgility pack as well as several methodologies from internet.

推荐答案

您无法获取数据,因为数据不存在。



首先,XPath是没用的,因为HTML不是XML。



HtmAgility Pack是你最好的选择处理HTML。



您还没有提供足够的信息,但看起来加载页面的javascript代码就是放置数据的原因。但是,由于当您使用您正在使用的任何代码加载页面时代码不会运行,因此数据不存在。
You can't get the data because the data isn't there.

First, XPath is kind of useless because HTML is NOT XML.

The HtmAgility Pack is your best bet for dealing with HTML.

You haven't supplied enough information, but it would appear that the javascript code loaded with the page is what is putting that data in place. But, since the code doesn't run when you load the page with whatever code you're using, the data doesn't exist.


这篇关于Web抓取C#无法获取页面源中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆