在服务器上使用curl - 如何将javascript请求重定向到目标服务器?

发布于 2024-12-18 14:23:26 字数 1140 浏览 2 评论 0原文

所以我在我的服务器上运行一个爬虫,我需要执行 javascript 来访问我的目标站点上的一些数据(目标是我想要爬行的站点)。我有一个关于这里问题的不同方法的问题,但不需要回答这个问题:[Dead]如何利用异步回发成功 POST 到旧的 ASP.NET 站点

我的 javascript 在我称为 my 的浏览器中执行php爬虫来自.问题是所有 javascript 请求都针对我自己的服务器而不是目标站点(我得到的链接是我自己的站点而不是目标站点上的 /index.php 之类的链接)。

我对 javascript 的经验非常少,我不知道应该如何将我的请求重定向到我的目标。这是我正在调用的页面中的 javascript 函数的示例:

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

...以及我调用它的方式:

echo "<SCRIPT language='javascript'>__doPostBack('-254870369', '')</SCRIPT>";

是否有某种方法可以将服务器地址从我自己的服务器别名到目标服务器或执行其他操作可以解决这个问题的方便的解决方法吗?

So I'm running a crawler on my server and I'm needing to execute javascript to gain access to some of the data on my target site (target being the one I want to crawl). I had a question regarding a different approach to the problem here, but it's not needed for answering this one: [Dead]How to successfully POST to an old ASP.NET site utilizing Asynchronous Postback

My javascript is executed in the browser I call my php crawler from. The problem is that all javascript requests are targeted back at my own server rather than the target site (I get lead to links like /index.php on my own site rather than the target site).

My experience with javascript is pretty minimal and I'm not sure how I should redirect my requests to my target. Here is an example of a javascript function from the page that I'm calling:

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

... and the way that I call it:

echo "<SCRIPT language='javascript'>__doPostBack('-254870369', '')</SCRIPT>";

Is there some way of aliasing the server address from my own server to the target server or doing some other kind of handy workaround that would fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪若未夕 2024-12-25 14:23:26

无需在目标中注入 javascript。
您可以使用wireshark来研究目标发出的所有请求。 Wireshark 是一个很难掌握但功能强大的工具。相反,您可以尝试 firebug 插件net 选项卡。

一旦您知道目标如何发送请求并从其服务器接收数据,您就可以使用curl来模拟请求/接收数据。您不再需要构建爬虫。

如果这不能回答您的问题,请详细解释一下该场景。

There is no need to inject javascript in the target.
You can use wireshark to study all request made by the target. Wireshark is a quite hard to master but powerful. Instead you can try the net tab of the firebug addon.

Once you know how the target send requests and receive data from their server, you can use curl to imitate the request/receiving data. You don't need any more to build crawlers.

If this not answers your question explain a little more the scenario.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文