Jump to content

Is my regex wrong ? Please hint only


Nuv

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/240333-is-my-regex-wrong-please-hint-only/
Share on other sites

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" />

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.