简体   繁体   English

我如何使用 php 访问 cgi 网页的特定外部页面

[英]how do I acces specific external page of cgi web page using php

I'm trying to calculate the average rainfall on a tuesday in 2014 so far vs other days.我正在尝试计算到目前为止与其他日子相比 2014 年星期二的平均降雨量。

http://www.knmi.nl/klimatologie/daggegevens/index.cgi has all the information needed, the only problem is that each day can not be accessed with a direct link. http://www.knmi.nl/klimatologie/daggegevens/index.cgi拥有所有需要的信息,唯一的问题是每天无法通过直接链接访问。 An on-screen form has to be used to select a day.必须使用屏幕表格来选择一天。

Is there a way to automatically download these pages or the information on these pages with php?有没有办法用php自动下载这些页面或这些页面上的信息?

EDIT: to be clear: I need all days from 2014, a day can be selected using the on-screen form.编辑:要清楚:我需要从 2014 年开始的所有日子,可以使用屏幕上的表格选择一天。

I have no experience with cgi whatsoever.我对 cgi 没有任何经验。

Yes there is a way and it has nothing to do with cgi.是的,有一种方法,它与 cgi 无关。 Regardless of the programming language used to build the site;无论用于构建站点的编程语言如何; realistically you are only interested in the output of the page, which is going to tbe html in this case.实际上,您只对页面的输出感兴趣,在这种情况下将是 html。

Use:用:

$site_html = file_get_contents('http://www.knmi.nl/klimatologie/daggegevens/index.cgi');

Now $site_html variable has the html output of the given page;现在$site_html变量具有给定页面的 html 输出; you just need to parse it to get the values you want.你只需要解析它以获得你想要的值。 I believe this is known as scraping web page.我相信这被称为scraping网页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM