Perl - 将Javascript操作提交给主持人 [英] Perl - Submit Javascript action to host

查看:62
本文介绍了Perl - 将Javascript操作提交给主持人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Perl中构建一个Spider并遇到问题:

I am building a Spider in Perl and have a problem:

我想蜘蛛网站使用JavaScript进行年龄验证,我不知道如何在Perl中通过这个...?

The Site I want to spider uses a JavaScript for Age-Verification and I don't know how to get past this in Perl...?

脚本如下所示:

<script type = "text/javascript">

function set_age_verified(){

    new Request({

        method: "post",

        url: "/user/set_age_verified"

    }).send();

    $('age_verification').setStyles({visibility: 'hidden', display: 'none'});

    $('page_after_verification').setStyles({visibility: 'visible', display: 'block'});

    return false;

}

</script>

这里的OnClick事件:

And here the OnClick Event :

<a href="#" onclick="return set_age_verified();"><img src="http://example.com/age-verification-enter.gif" alt="ENTER"></a>


推荐答案

该功能有两种效果。一种是将请求发布到URL/ user / set_age_verified,另一种是改变某些HTML的显示可见性。

The function has two effects. One is to POST a request to the URL "/user/set_age_verified" and the other is to alter the display visibility of some HTML.

你的蜘蛛很容易忽略第二个效果,但可能是第一个效果,通过转到服务器,设置服务器将需要的一些cookie或服务器变量。

Your spider can easily ignore the second effect, but presumably the first effect, by going to the server, sets some cookie or server variable which the server will require.

你没有必须实际运行javascript ,只要服务器看到相同的POST数据。

You do not have to actually run the javascript, so long as the server sees the same POST data.

答案是您的Perl脚本检测具有此javascript的页面,并调用Perl函数将数据POST到年龄验证URL。

The answer is for your Perl script to detect pages which have this javascript, and to call a Perl function to POST the data to the age verification URL.

任何返回的cookie或类似物都必须由您记录 - 您的HTTP库可能会为您处理此事。

Any cookie or similar which is returned will have to be recorded by you - your HTTP library may take care of this for you though.

这篇关于Perl - 将Javascript操作提交给主持人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆