1

I want to open some websites which may contain javascript code for example google analytics or piwik. I think the using a webclient is the easiest way to visit websites but does the webclient run javascript code in the background automaticly or how could I get javascriptcode running by visiting a website in C#?

5
  • What exactly do you need? When you say you need to "get javascript code running", do you mean that you want to be able to pull just the javascript code from an html website? Or are you saying you need to get the DOM after the javascript code has run? Commented Dec 8, 2014 at 17:28
  • I just need kind a kind of webbrowser which runs the javascript code on a website. I don't need to interact with this website in any way. Commented Dec 8, 2014 at 17:30
  • What you probably want then is a WebBrowser control. It acts like a mini web browser and you can set the visible property to false if you don't care about displaying any information. Commented Dec 8, 2014 at 17:33
  • I dont need any output to the user. It should be fast and liteweight Commented Dec 8, 2014 at 17:34
  • See my answer below. Commented Dec 8, 2014 at 17:40

4 Answers 4

1

Have you considered using a headless browser like PhantomJS.

Sign up to request clarification or add additional context in comments.

Comments

1

If you are looking for something with a UI interface, look at the WebBrowser Control.

If you need to just get the DOM or underlying elements of the DOM, I would suggest Watin. It is very mature and works well and its fast.

5 Comments

Does Watin run clientside code (javascript) from website automatic?
@razoR - yes. It does AJAX calls too
As I understand IE or FF needs to be installed and Watin just built a bridge for easy commands, am I wrong or did I need to configure anything before or does Watin contain IE? I'm not sure if each user of my app would have IE or Firefox installed.
It should only require that if you plan to install the plugins to be able to use Waitin directly from your browser. It shouldn't require a browser when using it programmically from C#.
Nice one. At least showed me a direction to work on.
0

WebClient only loads data from the web. It does not interpret it in any way.

If you need to treat the page the way a web browser would, then you need to use a Web Browser control.

Comments

0

in C# there is an Internet Explorer control. You can execute javascript code on a client PC by setting web URL link to this control. Internet Explorer control is a fully functional browser which executes all client code.

4 Comments

I think this is overloaded, I just need to visit pages and get javascript code runned (main goal are only analytic softwares). I don't need to get screenshots.
Actually, it's called the WebBrowser Control, and it's not part of C#. It's part of .NET.
sorry, I wasn't correct. it is WebBrowser Control. and you don't need to render web page on your form, the control can be hidden.
Unfortunately there is no any other ways how to run javascript code on client PC. Only client browser can execute all the code on client PC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.