简体   繁体   中英

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.

I maintain many automated weather stations that continually post data to various web severs/locations. 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. An example can be seen here: 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. 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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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