473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Regex Script Help

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

Expand|Select|Wrap|Line Numbers
  1.                                         <td width="55%"><div class="value">
  2.                                             &pound;6.99 <font size="3"> </font></div>
  3.  
  4.                                         </td>
With the "&pound;6.99" being what I want to extract and use. for example, this code works perfectly for a different website.

Expand|Select|Wrap|Line Numbers
  1. $url = 'http://www.cheapsmells.com/viewProduct.php?id=3462';
  2. $html = file_get_contents($url);
  3.  
  4. preg_match('/<div class=\'productOurPrice\'?>(.+?)(\d+\.\d+)(.+?)?<\/div>/', $html, $match);
  5. $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 would be greatly appreciated.

Cheers ;D
Feb 6 '08 #1
1 1238
pbmods
5,821 Expert 4TB
Ew. That's really unfortunate. They've got a doctype, they're using jQuery... it's like they're really trying... and then they go and dump a useless (and obsolete) font tag and an unexpected </div>.

Probably the new guy who transferred from a .NET project. You don't have to write any code for .NET, you know. It's all drag-and-drop (:

Until the abstraction leaks, of course (http://www.joelonsoftware.com/articl...tractions.html).

Anyway, on to your problem.

It looks like they've changed their markup. Here's the new HTML:
Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.                                         <td width="45%" class="price">OUR<br />PRICE</td>
  3.                                         <td width="55%"><div class="value">
  4.                                             &pound;6.99 <font size="3"> </font></div>
  5.  
  6.                                         </td>
  7.                                       </tr>
Jun 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alan Pretre | last post by:
Can anyone help me figure out a regex pattern for the following input example: xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m I would want four matches from this: 1. xxx a=b,c=d 2. yyy e=f 3....
0
by: Evgeny Zoldin | last post by:
Hi All, I want to capture the argument of some javascript function call in HTML source code, namely HTML-Page contains <script....> func ( 'something1\'something2' ); </script...> or
6
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
3
by: jg | last post by:
I made a mistake somewhere in my vb code and I look, check and read against the articles and help on regex, I still can't find the mistake I made. I know my test string and the test patterns...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
4
by: Chris | last post by:
Hi Everyone, I am using a regex to check for a string. When all the file contains is my test string the regex returns a match, but when I embed the test string in the middle of a text file a...
4
by: MooMaster | last post by:
I'm trying to develop a little script that does some string manipulation. I have some few hundred strings that currently look like this: cond(a,b,c) and I want them to look like this: ...
0
by: =?ISO-8859-15?Q?C=E9dric?= | last post by:
Hi all, I want to import a SQL script (SQLite) executing each queries separately. - I read the SQL file - I split the read string with the separator ";" - I execute each query string query...
2
by: beatTheDevil | last post by:
Hey guys, As the title says I'm trying to make a regular expression (regex/regexp) for use in removing the comments from code. In this case, this particular regex is meant to match /* ... */...
0
by: Karch | last post by:
I have these two methods that are chewing up a ton of CPU time in my application. Does anyone have any suggestions on how to optimize them or rewrite them without Regex? The most time-consuming...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.