[英]How to extract javascript links in an HTML document?
I am writing a small webspider for a website which uses a lot of javascript for links: 我正在为使用很多JavaScript链接的网站编写一个小型webspider:
<htmlTag onclick="someFunction();">Click here</htmlTag>
where the function looks like: 该函数如下所示:
function someFunction() {
var _url;
...
// _url constructed, maybe with reference to a value in the HTML doc
// and/or a value passed as argument(s) to this function
...
window.location.href = _url;
}
What is the best way of evaluating this function server-side so I can construct the value for _url? 在服务器端评估此功能的最佳方法是什么,以便我可以为_url构造值?
Not exactly sure what you're trying to accomplish. 不确定您要完成什么。
If you need to send these values to the server for processing, Ajax would be your best option. 如果您需要将这些值发送到服务器进行处理,那么Ajax将是您的最佳选择。
It should be a mess to do. 这应该是一团糟。 But it depends on a lot of params:
但这取决于很多参数:
Some hints that could do the trick, should to simply parse your html and use regex to catch http links where the onclick="someFunction();" 可以解决问题的一些提示,应该简单地解析您的html并使用正则表达式来捕获http链接,其中onclick =“ someFunction();” attribute is present.
属性存在。
If you need server-side processing, you need to either: 如果需要服务器端处理,则需要:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.