C#在抓取的页面上调用javascript

时间:2014-06-06 12:43:33

标签: c# javascript web-scraping

我正试图从页面(TripAdvisor)中削减成本。问题是我需要以几种不同的货币来削减成本,而且我无法以编程方式切换到不同的货币。

当我加载页面时,有这个元素

<script type="text/javascript">
var cookieDomain = ".tripadvisor.com";
var modelLocaleCountry = "US";
var ipCountryId = "274684";
var pageServlet = "Home";
var crPageServlet = "Home";
var cdnHost = "http://c1.tacdn.com";
var userLoggedIn = false;
var currentCurrency = 'EUR';
</script>

我需要重新加载页面,以便显示例如USD为

<script type="text/javascript">
...
var currentCurrency = 'USD';
</script>

能否请您重新加载页面并更改显示的货币?

加载页面的基础代码是:

var reviewUrl = String.Format("http://www.tripadvisor.com/Hotel_Review-d{0}-Reviews.html",tripAdvisorId);
var reviewDocument = new HtmlDocument();
reviewDocument.LoadHtml(Encoding.UTF8.GetString(new WebClient().DownloadData(reviewUrl));
//My assumption of how to continue
var scriptNode = reviewDocument.SelectNodes("//script").Where(node => Node.InnerText.Contains("currentCurrency")).FirstOrDefault();
scriptNode -> Replace currentCurrency property -> ReloadPage

0 个答案:

没有答案