-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

4
  • can you show your code what you tried so far. Commented Jun 7, 2014 at 6:27
  • ClientScript.RegisterClientScriptBlock(typeof(Page), "myscript", "RedirectToNextPage('210')", true); Commented Jun 7, 2014 at 6:32
  • I have used this code @Illaya Commented Jun 7, 2014 at 6:32
  • Tried like this...? stackoverflow.com/questions/1905716/… Commented Jun 7, 2014 at 6:39

2 Answers 2

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.

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

2 Comments

i am downloading browser. But how it will help me?
@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.
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

Comments

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.