在服务器上使用curl - 如何的JavaScript重定向请求到目标服务器? [英] Using curl on server - how to redirect javascript requests to target server?

查看:158
本文介绍了在服务器上使用curl - 如何的JavaScript重定向请求到目标服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我跑我的服务器上的履带,我需要执行JavaScript来获得我的目标站点访问某些数据(目标是一个我要抓取)。我有一个关于不同的方法来这里的问题一个问题,但它并不需要回答这一个:<一href=\"http://stackoverflow.com/questions/8283459/how-to-successfully-post-to-an-old-asp-net-site-utilizing-asynchronous-postback\">How以成功发布,以利用异步回老ASP.NET网站

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: How to successfully POST to an old ASP.NET site utilizing Asynchronous Postback

我的JavaScript是我称之为从我的PHP履带式的浏览器中执行。问题是,所有的JavaScript请求针对性回到我自己的服务器,而不是目标站点(我得到铅像的index.php链接对我自己的网站,而不是目标站点)。

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).

我使用JavaScript的经验是pretty最小的,我不知道我应该怎么我的请求重定向到我的目标。下面是从我打电话页面的JavaScript函数的例子:

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?

推荐答案

有没有必要在目标注入的JavaScript。
您可以使用 Wireshark的研究的目标所做的所有请求。 Wireshark是一个非常难掌握,但功能强大。相反,你可以尝试萤火虫插件标签。

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.

一旦你知道如何在目标从他们的服务器发送请求和接收数据,可以使用curl模仿请求/接收数据。你不需要任何更多的建立爬虫。

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.

这篇关于在服务器上使用curl - 如何的JavaScript重定向请求到目标服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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