wwwebsurfer All American 10217 Posts user info edit post |
I'm trying to pull just part of this page: http://mobile.weather.gov/port_mp_ns.php?select=3&CityName=Fayetteville&site=RAH&State=NC&warnzone=NCZ088
Namely, just the "Weather" and "Temp". I'd like to do it in-line with PHP, but I can't seem to get it to cooperate. I'm not above using an intermediate page processed and cached to feed the information, but I'm trying to avoid it.
Any ideas? 9/2/2010 1:45:01 PM |
FroshKiller All American 51911 Posts user info edit post |
You know the NWS has a public XML feed you can grab, right?
http://www.nws.noaa.gov/xml/
Here is my PHP implementation, which you are welcome to modify as needed:
<?php $xslDoc = new DOMDocument(); $xslDoc->load("./nwsweather.xslt");
$xmlDoc = new DOMDocument(); $xmlDoc->load('http://www.weather.gov/xml/current_obs/KRDU.xml');
$proc = new XSLTProcessor(); $proc->importStylesheet($xslDoc); echo $proc->transformToXML($xmlDoc); ?>
The file nwsweather.xslt was just an XSLT file I used to style the data in the text format I wanted.
This is probably all kinds of stupid, actually. I've just copied and pasted a broken old script I don't use anymore.
[Edited on September 2, 2010 at 1:54 PM. Reason : Wow, the CODE tag sucks here.]
[Edited on September 2, 2010 at 1:57 PM. Reason : why the fuck did i open that curl session holy christ]9/2/2010 1:46:12 PM |
wwwebsurfer All American 10217 Posts user info edit post |
no, no I did not know they published via XML. In fact I have an RSS reader that can rip through this for breakfast.
THANK YOU /thread
[Edited on September 2, 2010 at 1:53 PM. Reason : they need to make the stuff I want easier to locate ] 9/2/2010 1:53:29 PM |
Stein All American 19842 Posts user info edit post |
Quote : | "why the fuck did i open that curl session holy christ" |
Because cURL owns.
That's why.9/2/2010 3:29:46 PM |
FroshKiller All American 51911 Posts user info edit post |
You're right! But it was entirely redundant, and I didn't actually do anything with the resource it retrieved. 9/2/2010 4:12:10 PM |
qntmfred retired 40726 Posts user info edit post |
i do all my http requests in sockets
well technically i write assembly-generating php that makes http requests using sockets 9/2/2010 4:16:09 PM |
FroshKiller All American 51911 Posts user info edit post |
GET OUT 9/2/2010 4:16:38 PM |
Stein All American 19842 Posts user info edit post |
More like "suck-its". 9/2/2010 4:17:56 PM |
FroshKiller All American 51911 Posts user info edit post |
Quote : | "ASSEMBLY-
GENERATING
PHP" |
[Edited on September 2, 2010 at 4:18 PM. Reason : this may be my first three-word quote]9/2/2010 4:18:24 PM |
lewisje All American 9196 Posts user info edit post |
you can never understand it 'cause it happens too fast and it feels so good, it's like walking on glass 9/2/2010 11:05:30 PM |