Re: Intrepreting Javascript within C#



Logician,

Right, and using MSHTML, you would load the page, and then your bot
would manipulate the DOM to set the appropriate input. Once you do that,
the HTML engine will interpret the javascript and then you can access the
DOM to get whatever elements were changed to have the new URL.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Logician" <sales@xxxxxxxxxxxxx> wrote in message
news:1190130227.489343.197790@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 18, 4:00 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Logician,

If this is in the context of an HTML page, then why not use an HTML
document host like MSHTML to execute the javascript? You can then access
the document object model (DOM) after the javascript is executed, as well
as
set values on the page and see how the page reacts.
I'm not sure how that works. It is an HTML page but generated from
user input, eg a menu click. The bot has to read the js code and then
intrepret it to get the new url, then effectively visit the url. But
as the url is built at run time this is fairly hard.

I checked out some sites and saw, eg grohe.co.uk, that not even google
has indexed much of those sites.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Logician" <sa...@xxxxxxxxxxxxx> wrote in message

news:1190127053.123405.223420@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



Does anyone have any idea how this is done?

I am writing a c# bot to grab data from sites, but some sites have
extensive Javascript navigation. This means I have to read the script
and effectively run it within c#.
I have one example from a book (Http programming for bots using c#).
The problem I have is understanding how to setup the package and then
how to process the Javascript code on the site without actually in
effect copying the code.

JScript.Eval E = new JScript.Eval();
String expression = TextBox.Text;
try
{
TextBox1.Text = E.DoEval(expression);
}

JScript is defined as:

package JScript
{
class Eval
{
public function DoEval(expr:String):String
{
return eval(expr);
}
}
}- Hide quoted text -

- Show quoted text -




.



Relevant Pages

  • Re: JS, DOM and tr... IE problems!
    ... I've got a problem with javascript and DOM. ... Capitalisation is often used in HTML markup, ... If you post what your browser is actually getting (e.g. using view ...
    (comp.lang.javascript)
  • Re: Why doesnt IE show full html source?
    ... if you use smart navigation, javascript changes the dom on the fly, so the ... in turn is generated by javascript - for which you can see the source). ... need to use a dom inspector to see the changes made by smart nav. ... | Why does IE not show the full html source when I try to view the source?? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Intrepreting Javascript within C#
    ... that is usually an element in the HTML. ... the HTML engine will interpret the javascript and then you can access the ... So the bot needs to simulate the user input and then read the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Intrepreting Javascript within C#
    ... Right, and using MSHTML, you would load the page, and then your bot ... DOM to get whatever elements were changed to have the new URL. ... document host like MSHTML to execute the javascript? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Newbie Question on the Basics
    ... What is it in the HTML that calls the Javascript after every keypress? ... "onload" function then uses the DOM to locate nodes in the document ... It is not at all a means of graceful degradation. ...
    (comp.lang.javascript)