使用 PHP 从远程站点抓取时跟踪 Javascript 链接

发布于 2024-07-26 17:14:13 字数 470 浏览 1 评论 0原文

给定远程页面:

http://example.com/paged_list.aspx

使用 Javascript 函数调用显示多页表格数据:

javascript: show_page(1) javascript: show_page(2)

等等。 用户点击页面链接来显示每个页面,这会触发重新加载,但没有查询字符串,即 URI 保持不变。

在抓取该网站时,有一种方法来获取后续页面会很有用,但没有明显的方法可以在请求中指定页码(传递给 file_get_contents())。

有没有办法:

  1. 打开远程网址。
  2. 在该地址调用已知的 javascript 函数。
  3. 返回结果?

Given remote page:

http://example.com/paged_list.aspx

which uses a Javascript function call to display several pages of tabular data:

javascript: show_page(1)
javascript: show_page(2)

and so on. Users click on the page links to display each page, which triggers a reload but with no query string, ie the URI remains the same.

In scraping this site, it would be useful to have a way to obtain subsequent pages but there is no obvious way to specify a page number in the request (passed to file_get_contents()).

Is there any way to:

  1. Open a remote web address.
  2. Call a known javascript function at that address.
  3. Return the results?

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

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

发布评论

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

评论(2

挽手叙旧 2024-08-02 17:14:13

在 PHP 中模拟 JS 将是一条艰难的道路。 更容易分析JS源并确定后台AJAX操作的URL目标。 通过调用 URL 并根据需要修改 args,将整个数据集拉入 PHP 脚本应该是一项相当简单的任务。

Emulating JS in PHP would be the tough route. Much easier to analyze the JS source and determine the URL target of the background AJAX operation. Should then be a fairly easy task to pull the entire data set into your PHP script by calling the URL and modifying args as needed.

梦里梦着梦中梦 2024-08-02 17:14:13

您最好的选择是尝试对 php 脚本的 javascript 函数/ajax 调用进行逆向工程,以便使用正确的参数向他们的服务器发出您自己的请求。

您可以使用许多 Firefox 插件来让您的生活更轻松地逆转所有这些(例如,Firebug 通过查看网络活动)

Your best bet would be to try to reverse engineer the javascript function/ajax calls to their php script in order to do your own request to their server with the correct arguments.

You can use many firefox addons to make your life easier at reversing all of that (e.g. firebug by looking at network activity)

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