![]() |
preg_match_all
Hey, I'm trying to get data from retailmenot.com
This is what I have: PHP Code:
Any ideas? |
Correct me if I'm wrong but I always thought to get data from the regular expression into the resulting matches you had to use (.*?) - other than that don't have the time right now to sit down and look through your expression.
|
Quote:
Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) [3] => Array ( ) [4] => Array ( ) [5] => Array ( ) [6] => Array ( ) [7] => Array ( ) [8] => Array ( ) [9] => Array ( ) ) |
Oh and I forgot to ask is all this html really on the same line? if it's not then you need to add the modifier to ignore new lines...which is..god I can't remember for the life of me.
|
I think that may be why, I just used this:
preg_match_all('/<td class="code" id="(.*?)"><strong>(.*?)<\/strong>/', $page, $output); Instead of the whole area I need and brought back the coupons but I need the other areas too. |
I'm sure I wrote a class for this once, but I've wrote it again nevertheless as it's easy enough to write. It can be used as simple as this:
php Code:
You would then loop the results like so: html4strict Code:
...And finally the class itself :-) Enjoy it! Just give TalkPHP.com some credit when the opportunity arises. Please! php Code:
|
Thanks, appreciated :)
|
Hey, me again - for some reason the script stopped functioning, I'm guessing it's the regex and tried fixing it but I couldn't get it working again, any chance someone could look into it? Thanks
|
Their HTML has changed which means that the regex will need updating, it's a simple fix and one I'd encourage you to have a go at yourself.
|
Quote:
<td class="code" id="code.+?"> to <td class="code.+?" id="code.+?"> did the job, thanks :D |
I thought we could go on the same thread...
I have the following html or string $str: <div class="MutiStuffe"> <p><strong>Decription: </strong><br /> extra1, extra2, extra3, ..........extras50</p> </div> and I would like to match "extra1, extra2, extra3, ..........extras50" preg_match_all( "/\,(.*?)\</", $str, $array); matches from extra2 till extras50< including "<" But still not what I need. Thanks in advance for your proposals |
| All times are GMT. The time now is 10:49 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0