Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.