TFD3 Posted July 11, 2007 Share Posted July 11, 2007 Hi I am new to PHP and have gotten a lot better at it as time has went by. I make whats known as place files for a software package and PHP scripts are needed to make some of these work right. I am working on a new place file that I need php to make this work. On this webpage http://www.abc3340.com/static/skycams/demopolis.html is a list of current conditions. I need the temp extracted out of that URL but I am not sure how to go about doing this. Can anyone give me advice? any help what so ever it greatly appreciated!! Thanks, Kenny Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 use the get method $_GET['your_stuff_here']; then the link should look something like this href="x.php?your_stuff_here=ewan ko sayo" now echo $_GET['your_stuff_here']; will give you ewan ko sayo does ti make sense Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 use the get method $_GET['your_stuff_here']; then the link should look something like this href="x.php?your_stuff_here=ewan ko sayo" now echo $_GET['your_stuff_here']; will give you ewan ko sayo does ti make sense not really. I need 72° extracted from that URL i posted. I have not used the get method yet. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 http://w3schools.com/php/php_get.asp Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 http://w3schools.com/php/php_get.asp Have already read that page and will not help me with what im needing. If you know how can you make the script and post it here? Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 anyone else have an idea on how to extract just the Current Temp out of that website in text format? Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 on this page I just need the Temperature in blue along with the degree sign extracted. Can someone make a PHP script that can do just this using the URL thats posted above. I have no idea what im doing as I have not had to do this before. Im sure someone on here knows how Quote Link to comment Share on other sites More sharing options...
rcorlew Posted July 11, 2007 Share Posted July 11, 2007 They might not like this but here is how you do it: <?php $handle = fopen("http://www.abc3340.com/static/skycams/demopolis.html", "r"); $contents = stream_get_contents($handle); $pos = strpos($contents, "°"); $end = $pos - 3; $string = substr($contents, $end, 4); $string = str_replace('>', ' ', $string); fclose($handle); echo "$string"; ?> All you have to do is add whatever styling you want to the string which will only be the temperature. Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 They might not like this but here is how you do it: Well then all you have to do is change: $handle = fopen("http://www.abc3340.com/static/skycams/demopolis.html", "r"); to $handle = fopen("http://beta.alabamaweather.org/places/textversion/extra_stations/demopolis_raw.php", "r"); Thanks for your help!!! Quote Link to comment Share on other sites More sharing options...
rcorlew Posted July 11, 2007 Share Posted July 11, 2007 NO, usually web sites do not want you accessing their pages without permission. You need to check to see if it is copyrighted. And the first code is what you need, just use wisely as it increases traffic on their site, and it will show your ip and other user information about you whenever you access the page(it will show the server you access the script from). Cheers. Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 NO, usually web sites do not want you accessing their pages without permission. You need to check to see if it is copyrighted. And the first code is what you need, just use wisely as it increases traffic on their site, and it will show your ip and other user information about you whenever you access the page(it will show the server you access the script from). Cheers. its not a problem, I have consent from the chief met at the station! Quote Link to comment Share on other sites More sharing options...
rcorlew Posted July 11, 2007 Share Posted July 11, 2007 Well there you go, you are lucky to have actually gotten permission, good job on that. The script will work perfectly as long as the page remains fairly consistent to what it is now, it will go from -99 degrees all the way to 999 degrees, is that good enough? Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 Well there you go, you are lucky to have actually gotten permission, good job on that. The script will work perfectly as long as the page remains fairly consistent to what it is now, it will go from -99 degrees all the way to 999 degrees, is that good enough? Yeah James Spann is a good met, he lets me use his skycam images as well! Yeah I think -99 to 999 is a good rang, should be able to get every temp reported Quote Link to comment Share on other sites More sharing options...
TFD3 Posted July 11, 2007 Author Share Posted July 11, 2007 now that I got the script working, this is what its for Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.