Solved

Grabbing A Remote URL

Posted on 2000-05-11
7
208 Views
Last Modified: 2006-11-17
I am trying to get the information from http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian_Weather and post it on a local page.

I can get the info fine but I want to display only part of the page. Here are the parts I don't want to show:

- Anything before the actual start of the report.

- And nothing after the end of the report. IE: Not the horizontal rules.

Any ideas?
0
Comment
Question by:phreakin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2800714
Which part would you like ??


FZHW50 PHFO 110000
NSHHFO
SURF OBSERVATIONS AT SELECTED OAHU BEACHES
NATIONAL WEATHER SERVICE HONOLULU HI
2 PM HST WED MAY 10 2000
AFTERNOON  

BEACH             HEIGHTS               REMARKS

EHUKAI             FLAT TO 1              1 PM
SUNSET             FLAT TO 1              1 PM
MAKAPUU            2 TO 4                 1 PM
SANDY BEACH        2 TO 4                 1 PM
DIAMOND HEAD       2 TO 3 OCNL 4          7 AM
WAIKIKI            2 TO 3                 1 PM
ALA MOANA          2 TO 3                 1 PM
NANAKULI           FLAT TO 1              9 AM
MAKAHA             FLAT TO 1              1 PM

SURF ALONG THE SOUTH SHORES WILL BE 1 TO 3 FT TODAY AND WILL
BECOME HIGHER WITH HEIGHTS OF 3 TO 5 FT BY LATE AFTERNOON AND
THURSDAY.

SURF ALONG THE EAST AND WEST SHORES WILL BE 2 TO 3 FT OCNL 4 FT
THROUGH THURSDAY.

SURF ALONG THE NORTH SHORES WILL BE FLAT TO 1 FT THROUGH
THURSDAY.
0
 

Author Comment

by:phreakin
ID: 2800739
SURF OBSERVATIONS AT SELECTED OAHU BEACHES
NATIONAL WEATHER SERVICE HONOLULU HI
2 PM HST WED MAY 10 2000
AFTERNOON    

BEACH             HEIGHTS               REMARKS

EHUKAI             FLAT TO 1              1 PM
SUNSET             FLAT TO 1              1 PM
MAKAPUU            2 TO 4                 1 PM
SANDY BEACH        2 TO 4                 1 PM
DIAMOND HEAD       2 TO 3 OCNL 4          7 AM
WAIKIKI            2 TO 3                 1 PM
ALA MOANA          2 TO 3                 1 PM
NANAKULI           FLAT TO 1              9 AM
MAKAHA             FLAT TO 1              1 PM

SURF ALONG THE SOUTH SHORES WILL BE 1 TO 3 FT TODAY AND WILL
BECOME HIGHER WITH HEIGHTS OF 3 TO 5 FT BY LATE AFTERNOON AND
THURSDAY.

SURF ALONG THE EAST AND WEST SHORES WILL BE 2 TO 3 FT OCNL 4 FT
THROUGH THURSDAY.

SURF ALONG THE NORTH SHORES WILL BE FLAT TO 1 FT THROUGH
THURSDAY.

0
 
LVL 8

Expert Comment

by:us111
ID: 2801742
ok, below is the HTML source of the page.
Is the HTML source always the same ??
I mean
<pre>
FZHW50 PHFO 110000
NSHHFO
blablabla
</pre> ?

And you need blablabla...

Do you already have these 2 lines ??

FZHW50 PHFO 110000
NSHHFO

0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:phreakin
ID: 2801761
I would assume those lines change, I just need to get the info from the report. The only really important part to chop off would be the bottom part. I could live with the rest.
0
 

Accepted Solution

by:
Agent_Neo earned 50 total points
ID: 2802250
Here is the script in php to do what you want.

<?php
### Grab URL DATA ###
$url_report = fopen("http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian$

### Parse Report Lines ###
while (!feof($url_report)) {
  $buffer = fgets($url_report, 4096);
  if ($buffer == "<HR>\n") { $found=true; } # Cut off Area
  if ($found == true) {
        Skip;
  }
        else {
                if ($buffer != "<pre>\n" && $buffer != "</pre>\n") { $data .= $buffer;}
  }

}
### Close Report ###
fclose($url_report);

$data = strip_tags($data); # Strip HTML Tags
print $data; # Print Report

?>
0
 

Expert Comment

by:Agent_Neo
ID: 2802258
My Bad. I was copying from Pico (Linux) and din't see I didnt copy all the code:

Where it says:
$url_report

Replace it with this:
$url_report = fopen("http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian_Weather","r");
0
 
LVL 8

Expert Comment

by:us111
ID: 2803446
Less code and only one access to the URL:

<?
$url_report = file("http://lumahai.soest.hawaii.edu/cgi-bin/text2.csh?SURFOBS.PHFO,Surf_Observations,Hawaiian_Weather");

$new_url="";
while (list($index, $value) = each($url_report))
{       $new_url.="<br>".$value;
}

$new_url = split("<pre>", $new_url);
$new_url = split("</pre>", $new_url[1]);
print $new_url[0];
?>
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question