Jump to content

Novice Script Help


e1seix

Recommended Posts

I think I did post this some time ago, but can't find original thread to rehash. I have some questions regarding lifting data from a particular webpage. What makes this unusual and why I need to ask some questions is that within the tags, there is a lot of white space and the data doesn't actually sit within closed tags eg. <span>data</span>, it falls like this

 

                                        <td width="55%"><div class="value">
                                            £6.99 <font size="3"> </font></div>
									    
                                        </td>

 

With the "£6.99" being what I want to extract and use. for example, this code works perfectly for a different website.

 

$url = 'http://www.cheapsmells.com/viewProduct.php?id=3462';
$html = file_get_contents($url);

preg_match('/<div class=\'productOurPrice\'?>(.+?)(\d+\.\d+)(.+?)?<\/div>/', $html, $match);
$out = $match[2];

 

Where the url is http://www.directcosmetics.com/results/products.cfm?ctype=ME&range=Hummer&code=34744 which is where the first example where the whitespace is, how can I adjust the above regex to obtain the information required, in this case literally "6.99" and nothing more. Is it possible because it's not within closed brackets?

 

Any help you can shed my way wouldbe greatly apprecviated.

 

Cheers  ;D

Link to comment
Share on other sites

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.