Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab info from website

Status
Not open for further replies.

Netwrkengeer

IS-IT--Management
Apr 4, 2001
184
US
I'm trying to use Post to send info to a website, which is working fine. the problem is I want to grab info from the site and echo it. this is not working.
Here is what I have so far, Thanks for looking..
-_______________________________________________-
Code:
<HTML>
<HEAD>
<TITLE>Geo</TITLE>
<BODY>

Please press submit to confirm</P>

<!--the form attempts to send info via &quot;POST&quot; to geocode.com for processing-->

<FORM name=&quot;form1&quot; method=&quot;post&quot; action=&quot;[URL unfurl="true"]http://geocode.com/scripts/eagle/eagle.pl&quot;>[/URL]
  
 <input type=hidden name=&quot;cmd&quot; value=&quot;td_a&quot;>
  Street Address: <INPUT SIZE=30 NAME=&quot;street&quot;><br>
                  City: <INPUT SIZE=30 NAME=&quot;city&quot;><br>
                 State: <INPUT SIZE=3 NAME=&quot;state&quot;> <br>
		 Zip: <INPUT SIZE=6 NAME=&quot;zip&quot; <br>
  <INPUT type=&quot;hidden&quot; name=&quot;request&quot; value=&quot;Address Info&quot;>
  <input type=hidden name=&quot;port&quot; value=&quot;7173&quot;>
</p><INPUT type=&quot;submit&quot; name=&quot;Accept&quot; value=&quot;Submit&quot;>
</FORM>
<?php 
/* 
overview of code.
To submit info to a website via above form, utilize Php to loop through website out put, to find and echo Lat. and Long. points.
*/ 
/* get site info*/

$filename = &quot;[URL unfurl="true"]http://www.geocode.com/scripts/eagle/eagle.pl/&quot;;[/URL]

$fc = @file($filename);

$full_contents = @implode(&quot;&quot;,$fc);

/*looping through html of site to find line 241 and 252 then echo both lines*/
while (list($line, $content)=each($fc)) {
     if($line == 241) {
          $lat = &quot;$content&quot;;
     }

     if($line == 252) {
          $long = &quot;$content&quot;;
     }
}

echo $lat;
echo $long;

?>
</BODY>
</HTML>
-_______________________________________-
 
you may want to try fopen($filename, &quot;r&quot;);
$fc = @file($filename); ***************************************
Party on, dudes!
[cannon]
 
Nope - - I tried it and it just sends me to the geo link, it doesn't actually get the info from the page.

Code:
<?php 
/* 
overview of code.
To submit info to a website via above form, utilize Php to loop through website out put, to find and echo Lat. and Long. points.
*/ 
/* get site info*/

$filename = &quot;[URL unfurl="true"]http://www.geocode.com/scripts/eagle/eagle.pl/&quot;;[/URL]
fopen($filename, &quot;r&quot;);
$fc = @file($filename);

$full_contents = @implode(&quot;&quot;,$fc);

/*looping through html of site to find line 241 and 252 then echo both lines*/
while (list($line, $content)=each($fc)) {
     if($line == 241) {
          $lat = &quot;$content&quot;;
     }

     if($line == 252) {
          $long = &quot;$content&quot;;
     }
}

echo $lat;
echo $long;

?>
</BODY>
</HTML>
 
OK, this actually works .. But not with the URL you have supplied. (you need to miss the trailing / and login first I guess) :)

<?php

$sourcefile=&quot;your_source_file&quot;;
$file = fopen(&quot;$sourcefile&quot;, &quot;r&quot;);

if (!$file)
{
echo &quot;<p>Unable to open remote file.\n&quot;;
exit;
} else {

$fcontents = file($sourcefile);

while (list ($line_num, $line) = each ($fcontents))
{

if ($line_num == &quot;241&quot;)

{

$lat = $line;

} else{

if ($line_num == &quot;252&quot;)

{

$long = $line;

}
}

}

echo $lat;
echo $long;
$fp=fclose($file);

}

?> ***************************************
Party on, dudes!
[cannon]
 
I tried what your code, but like you said it doesn't work, I previously used a code that would use post to submit the variables to the sites URL, which is how the company used to have it set up, but the company changed its site, now the site itself uses post to submit the variables to a file &quot;eagle.pl&quot;. I can post the varibles from my site to the &quot;eagle.pl&quot; file, the issue is, after I post I visually get the output to the monitor, I want the output(Html) from the site to be put into my variable &quot;$sourcefile&quot; so I can search it via (while loop)..? Can you help..?

site info..
The site allows you to test the software

it posts your info to
at which time you submit the info to the server

My original script was setup to skip the first page and post directly from..

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top