Nuv Posted June 24, 2011 Share Posted June 24, 2011 When i used the form i get the output however if i directly use this regex to the scraped data it won't work. I would request gurus not to solve it and give the answer completely as i am fed up at being bad at it and that won't help me.I would request them to hint me to the right direction.Is my regex wrong ? <?php $data = '<td class="cellborder" style="padding-left:5px; padding-right:3px;" width="40%"> <div id="opp_76766264"> <a target="_blank" href="/preisvergleich/Relocate/76766264.html?productid=531629&type=offer&sid=9441&price=81.94&categoryId=2925&pos=1&search=5995363702720" rel="nofollow" onmousedown="nlo(this.href)" style="text-decoration:none;" class="b"> 81,94 € </a> [b][i]SOME HTML HERE[/i][/b] <span class="nobr"> <img src="/pics/rating/orange.gif" width="10" height="10" alt="Besucher-Shopbewertung für shoppingfever.de: Note 1,0" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /> </span>'; $regex = '~\<div\sid="opp_.*href="(.*?)"\srel.*\<span\sclass="nobr"\>(.*?)\</span\>~s'; preg_match($regex, $data, $out); ?> Quote Link to comment https://forums.phpfreaks.com/topic/240333-is-my-regex-wrong-please-hint-only/ Share on other sites More sharing options...
Nuv Posted June 24, 2011 Author Share Posted June 24, 2011 Oh and i need /preisvergleich/Relocate/76766264.html?productid=531629&type=offer&sid=9441&price=81.94&categoryId=2925&pos=1&search=5995363702720 AND <img src="/pics/rating/orange.gif" width="10" height="10" alt="Besucher-Shopbewertung für shoppingfever.de: Note 1,0" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /><img src="/pics/rating/orange.gif" width="10" height="10" alt="" border="0" /> Quote Link to comment https://forums.phpfreaks.com/topic/240333-is-my-regex-wrong-please-hint-only/#findComment-1234477 Share on other sites More sharing options...
.josh Posted June 24, 2011 Share Posted June 24, 2011 can't say for certain...would help if you could post link to page you're actually trying to scrape. Perhaps the content is dynamically generated by js or perhaps it is within an iframe not actually on the page you're scraping. But one guess is perhaps your greedy quantifiers are killing it. Quote Link to comment https://forums.phpfreaks.com/topic/240333-is-my-regex-wrong-please-hint-only/#findComment-1234480 Share on other sites More sharing options...
Nuv Posted June 24, 2011 Author Share Posted June 24, 2011 Thankyou. I made them lazy and it worked. My mind goes when it comes to recursive functions,classes and regex. Quote Link to comment https://forums.phpfreaks.com/topic/240333-is-my-regex-wrong-please-hint-only/#findComment-1234484 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.