How can I scrap tc_vars from scrip tag?

Hello !

I wonder if it's possible to get informations from script tag "tc_vars" ?

I can see the ean code in the console "tc_vars["product_ean"]="8718819377054";" but I can't get it.

Here's the URL -> https://www.boulanger.com/ref/1137740

Do you have an idea ? Thanks a lot !

Assuming the code is always in <head> and the EAN is always digits, you can extract it with:

Type: HTML
Selector: head
Regex: (?<=product_ean"\]=")[\d]+

You must copy / type in the regex exactly. Every single character is important, and do not leave a space before or after.

2021-02-01_201533

2 Likes

It's work perfectly !

Thanks !!

Back again with this URL Hp - HP Pavilion Desktop TP01-2220nf - Blanc - PC Fixe - Rue du Commerce

I'm trying to get this EAN code 0196337970014 from the script tag.

I've tried several Regex lines but I don't understand how it works..

Any help ? Thanks !

For this example, the EAN seems to be stored within <head> tags so you can get at it with this regex:
(?<="ean":")\d+

Sitemap:
{"_id":"get-ean","startUrl":["https://www.rueducommerce.fr/p-hp-pavilion-desktop-tp01-2220nf-blanc-hp-3428970-25771.html"],"selectors":[{"id":"Title","multiple":false,"parentSelectors":["_root"],"regex":"","selector":"h1 > span","type":"SelectorText"},{"id":"EAN","multiple":false,"parentSelectors":["_root"],"regex":"(?<=\"ean\":\")\\d+","selector":"head","type":"SelectorHTML"}]}