php http 发布按钮

发布于 2024-09-08 12:01:28 字数 420 浏览 1 评论 0原文

我正在使用 PHP 来抓取另一个网站的数据。然而,在某些情况下,我需要确认一个变量(由于有两种非常相似的可能性)。

我应该单击以确认我的变量的按钮是:

<input type="submit" class="buttonEmphasized confirm_nl" name="start" value="Bevestig"  accesskey="s" />

但是,将 &start=Bevestig 添加到 url 似乎并不能解决问题,并且我收到相同的页面。更重要的是,该网站正在使用会话,并且每个 http_post_data 似乎都在开始一个新会话。

如果缺少某个输出,有没有办法让 PHP“单击”按钮?

这是一个火车时刻表数据抓取系统(使用HAFAS系统)。

干杯

I'm using PHP to data scrape another website. However, on certain occasions I need to confirm a variable (due to have two very alike possibilities).

The button I'm supposed to click to confirm my variable is:

<input type="submit" class="buttonEmphasized confirm_nl" name="start" value="Bevestig"  accesskey="s" />

However, adding &start=Bevestig to the url doesn't seem to solve the problem, and I'm receiving the same page. What's more, is that the website is using sessions and every http_post_data seems to be starting a new session.

Is there a way to let PHP "click" a button if a certain output is missing?

This is a train time table data scraping system (using the HAFAS system).

Cheers

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

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

发布评论

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

评论(3

鱼窥荷 2024-09-15 12:01:28

这个问题没有通用的解决方案。每个网站在某种程度上都是不同的。最好的办法是分析原始页面发送的http消息。例如,您可以使用 firefox+firebug+live http headers 来做到这一点。这样您将看到所有参数(必需或不需要),然后使用脚本复制此消息。

它可能(很可能)需要伪造会话/cookie 数据。你可能需要使用curl来实现这一点。

there is no generalized solution for this problem. every site is different in some way. your best bet is to analyze http message being sent by the original page. you can do it with firefox+firebug+live http headers for example. this way you're going to see all the parameters(required or not) and then replicate this message with your script.

it might(will, most likely) require faking session/cookie data. you might need to use curl for that.

多情出卖 2024-09-15 12:01:28

如果该帖子似乎正在开始一个新会话,我会怀疑您没有尊重对方提供的 cookie。

您需要在 POST 请求中发回会话 cookie。

这也是您应该发送起始字段的位置。虽然许多页面将接受 URL 或发布中的参数,但它们不是等效的概念。

If the post seems to be starting a new session, I would suspect that you are not respecting the cookies that were provided by the other side.

You need to send the session cookies back in the POST request.

That's also where you should be sending your start field. While many pages will accept parameters in URL or posted, they are not equivalent concepts.

江城子 2024-09-15 12:01:28

“如果缺少某个输出,有没有办法让 PHP“单击”按钮?”

不,PHP 是服务器端的。使用 JavaScript

"Is there a way to let PHP "click" a button if a certain output is missing?"

Nop, PHP is server-sided. Use Javascript

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