-1

I have developed crawler in C#.

I am reading data from one page that is list page, It uses javascript for redirecting to next page.

function is - <a onclick="redirectToNextPage(PageID)">More</a>

How i can run this function in serverside and get url of the next page, so that by that url i can save that page.

I want to run javascript function in C# to get url of next page

Hitesh Modha
  • 2,740
  • 5
  • 28
  • 47

2 Answers2

2

You'll almost certainly need a headless browser to do that, not just running JavaScript code without the context it expects to run in. This question and its answer list some headless browsers that can be used from C# (not all of them have JavaScript support, though). That list may well be out of date now, but that's the term you need to search for.

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • i am downloading browser. But how it will help me? – Hitesh Modha Jun 07 '14 at 06:37
  • @HiteshModha: Because a *headless* browser is run from code. So in code, you use the headless browser to load a page, then use its features to find the links, and use its features to tell it to "click" a link. In a headless browser that has JavaScript support, you'll be able to run the JavaScript associated with that link. – T.J. Crowder Jun 07 '14 at 06:39
0

Try https://javascriptdotnet.codeplex.com/.

It exposes Google V8 JS engine to CLI and also allows to CLI objects to be manipulated by JS

Ankit Sinha
  • 421
  • 3
  • 11