简体   繁体   English

如何在服务器端的C#搜寻器中运行javascript代码

[英]how to run javascript code in C# crawler on server side

I have developed crawler in C# . 我已经在C#开发了搜寻器。

I am reading data from one page that is list page, It uses javascript for redirecting to next page. 我正在从列表页面的一页读取数据,它使用javascript重定向到下一页。

function is - <a onclick="redirectToNextPage(PageID)">More</a> 函数是- <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. 我如何在服务器端运行此功能并获取下一页的URL,这样我可以通过该URL保存该页面。

I want to run javascript function in C# to get url of next page 我想在C#中运行javascript函数以获取下一页的网址

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). 您几乎肯定会需要一个无头浏览器来做到这一点,而不仅仅是在没有预期运行上下文的情况下运行JavaScript代码。 此问题及其答案列出了一些可从C#使用的无头浏览器(并非所有浏览器都支持JavaScript) )。 That list may well be out of date now, but that's the term you need to search for. 该列表现在可能已经过时,但这是您需要搜索的术语。

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

It exposes Google V8 JS engine to CLI and also allows to CLI objects to be manipulated by JS 它将Google V8 JS引擎公开给CLI,并允许JS处理CLI对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM