简体   繁体   English

从多个HTML页面“查询”多个数据元素的最佳方法

[英]Best approach to “query” multiple data elements from multiple html pages

Let me start by stating that I am very much a beginner with PHP but have enough programming experience with other languages that I'd like to skip the absolute basics and focus on the functions that will best satisfy what I'm trying to accomplish. 首先,我要说我是PHP的初学者,但是对其他语言有足够的编程经验,所以我想跳过绝对的基础知识,而专注于最能满足我要完成的功能。

I maintain many automated weather stations that continually post data to various web severs/locations. 我维护着许多自动气象站,这些气象站不断将数据发布到各种Web服务器/位置。 One way in which data from each station is posted is a list of data element labels and tag values as a simple html web page on an FTP server. 发布每个工作站的数据的一种方式是将数据元素标签和标签值的列表作为FTP服务器上的简单html网页发布。 An example can be seen here: ftp://ftp.udot.utah.gov/r1udot/weather/R1WS-1435-UDOT/WeatherLink/Images/AllVP2Tags.htm 可以在此处看到示例: ftp : //ftp.udot.utah.gov/r1udot/weather/R1WS-1435-UDOT/WeatherLink/Images/AllVP2Tags.htm

From approximately 25 pages similar to the example, I want to figure out the best approach to "query" specific data values from any number of corresponding labels. 从类似于示例的大约25页中,我想找出从任意数量的相应标签中“查询”特定数据值的最佳方法。 For example: I'd like to display a table with the Station Name (from line/row 1) and the Outdoor Temperature (from line/row 30) for all 25 stations (or from all 25 web pages.) From there, I'll probably be interested in creating the ability to "turn on/off" any of the stations and specify what data elements are listed. 例如:我想显示一个表,其中包含所有25个站点(或所有25个网页)的站点名称(从行/行1开始)和室外温度(从行/行30开始)。可能会对创建“打开/关闭”任何站点并指定列出哪些数据元素的功能感兴趣。

I'm assuming this is probably fairly simple and straightforward and am looking for suggestions as to what functions might be considered the best approach. 我假设这可能非常简单明了,并且正在寻找有关哪些功能可能被认为是最佳方法的建议。 Thanks!! 谢谢!!

The example page you listed uses a table to format the data. 您列出的示例页面使用表格来格式化数据。 Because of this you will need to find a DOM parser in PHP that works for you. 因此,您将需要在PHP中找到适合您的DOM解析器。

Then you should loop through the table rows and extract the rows that are of interest to you. 然后,您应该遍历表行并提取您感兴趣的行。 You should not assume that the order of the key/values will always be the same, instead you should match the strings of the key and then extract both the key/value into an array. 您不应该假设键/值的顺序将始终相同,而是应该匹配键的字符串,然后将键/值都提取到数组中。 At this point you are free to do whatever with the data. 此时,您可以随意处理数据。

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

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