Page 1 of 1

Getting weather report

Posted: Wed Sep 16, 2009 8:12 am
by zomgwtfbbq
Hello,

I'm trying to get the latest weather report from a website, so when I'm on the move I can see if I'm getting wet or not..:p
Anyways, I've tried lots of patterns already using preg_match_all.. but or I end up getting way too much data or nothing at all.
Yes I kind of suck at it, it's been a while since I last used regexes as well.

I'm trying to get just two parts in the code

Code: Select all

<a href="http://www.site.nl/report/today" title="[b]Report for 15-09-2009 generated at 15:00[/b]" class="weather" target="_blank"><img src="[b]http://www.site.nl/bla/bla/somelocation.jpg[/b]"></a>
Any help would be greatly appreciated... :D

Re: Getting weather report

Posted: Wed Sep 16, 2009 8:15 am
by superdezign
zomgwtfbbq wrote:

Code: Select all

<a href="http://www.site.nl/report/today" title="[b]Report for 15-09-2009 generated at 15:00[/b]" class="weather" target="_blank"><img src="[b]http://www.site.nl/bla/bla/somelocation.jpg[/b]"></a>
If that is the exact HTML, then you could easily use this regex:

Code: Select all

~<a href="http://www.site.nl/report/today" title="[b](.+?)[/b]" class="weather" target="_blank"><img src="[b](.+?)[/b]"></a>~

Re: Getting weather report

Posted: Wed Sep 16, 2009 8:19 am
by zomgwtfbbq
superdezign wrote:
zomgwtfbbq wrote:

Code: Select all

<a href="http://www.site.nl/report/today" title="[b]Report for 15-09-2009 generated at 15:00[/b]" class="weather" target="_blank"><img src="[b]http://www.site.nl/bla/bla/somelocation.jpg[/b]"></a>
If that is the exact HTML, then you could easily use this regex:

Code: Select all

~<a href="http://www.site.nl/report/today" title="[b](.+?)[/b]" class="weather" target="_blank"><img src="[b](.+?)[/b]"></a>~
Thanks for the fast reply, will try it when I'm home.

Thanks again. :)

Re: Getting weather report

Posted: Wed Sep 16, 2009 1:52 pm
by pickle
If you're in Canada/US, there is an RSS feed for your weather - which may be easier to parse.