Skip to content

Scraping using Regex

With Price Comparison Pro, you can scrape using CSS, xPath and Regex. In this KB, you’ll see how to scrape usuing Regex.

Many websites now provide schema.org JSON objects inside their raw HTML which you can scrape with Price Comparison Pro.

Here is an example schema.org JSON object with matching regex:

To grab the price from this, the regex would be:

/"price": "([^"]+)"/
  1. First, there are wrapping / characters to contain the expression.
  2. Next, the identifying marker before the price value. In this case it’s “price”: “
  3. Then the capturing area inside ( circular brackets ) – in this capturing area we are saying [^”]+. [] means any of the characters inside these brackets. The ^ is a special character to say any character except the following character. So [^”] means match any character except a double quote. Matching a double quote would mean we know the price value has ended. Finally, the + after the square brackets says match 1 or more character.
  4. Then we have the closing ” symbol and finally the closing /

To use Regex in Price Comparison Pro, you do so in the same way you configure CSS or xPath. Visit Settings > Price Comparison Pro > Price Comparison and choose ‘Expression Type’ of RegEXP.

Did this article answer your question?

Related Articles

Leave a Reply

Your email address will not be published.


Come chat to me on our Discord server to ask questions - Dave Hilditch, WP Intense

We use cookies

We use cookies for various things on our site, including our on-site chat bubble (if you use it), our comment forms (if you use them) and for session handling (if you log in).

Other than that, we use cookies to identify where traffic came from to help us understand which traffic turns into sales, we use a cookie for Google Analytics traffic analysis and we use a cookie to customise adverts for our own products we think you'll be interested in.

You can read more detail in our privacy policy page. Please click 'Accept' or 'Decline' to continue.