1

I try to parse HTML using HtmlAgilityPack using simple doc.load method by passing the URL, but it comes with the following result how can I resolve this issue?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function setCookie(c_name, value, expiredays) { 
  var exdate = new Date(); 
  exdate.setDate(exdate.getDate()+expiredays); 
  document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";
  expires=" + exdate.toGMTString()) + ";path=/"; } 
  function getHostUri() 
  { var loc = document.location; return loc.toString(); }
  setCookie('YPF8827340282Jdskjhfiw_928937459182JAX666', '202.142.170.42', 10); 
  setCookie('DOAReferrer', document.referrer, 10); location.href = getHostUri();
</script>
</head>
<body>
<noscript>This site requires JavaScript and Cookies to be enabled. Please change your   browser settings or upgrade your browser.</noscript>
</body></html>
Invinsible
  • 31
  • 1
  • 5

1 Answers1

1
This site requires JavaScript and Cookies to be enabled. Please change your browser settings or upgrade your browser.

This Message says it all, the side needs javascript to be loaded, and HtmlAgilityPack is no JavascriptEngine!

The Load Method of the HtmlDocument can not interpret and execute Javascript-Code it´s just a simple "Download"-Function for static HTML-Sites.

What you could try to do is, with Firebug (or something else) check which HttpRequest are made to get the content, and this Requests you have to recreate in C# to get the HTML you want!

Here are some similar Questions:

Running Scripts in HtmlAgilityPack

C# - Get JavaScript variable value using HTMLAgilityPack

Calling javascript function from HtmlAgilityPack

Community
  • 1
  • 1
makim
  • 3,154
  • 4
  • 30
  • 49