This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Online quotes - regex

Tags: None
(comma "," separated)
stephanesp
Registered Member
Posts
31
Karma
0

Online quotes - regex

Fri Apr 26, 2019 5:37 am
Hi,

I am trying to configure my own online quotes, to use boursorama.

Here is what I have:
url: https://www.boursorama.com/bourse/opcvm/cours/%1
Price: Cours\D*([\d, ]+\.\d+)
Date: dernier cours connu au\ (.*)\.
Date format: %d/%m/%y

This seems to work most of time, except when the name of stock to retrieve contains digits, e.g. https://www.boursorama.com/bourse/opcvm ... 0000448870

Has anybody got any idea how to better set up this?

Thanks a lot

Steven
User avatar
ipwizard
KDE Developer
Posts
1359
Karma
6
OS

Re: Online quotes - regex

Sun May 05, 2019 2:32 pm
I downloaded the data from the link you provided and found the following block beginning on line 1581 and marked the interesting bits in red:
<header class="l-quotepage__header">
<div class="c-faceplate c-faceplate--fund is-positive /*debug*/"
data-faceplate
data-faceplate-symbol="MP-803396"

><input type="checkbox" id="faceplate-1786588990" class="c-faceplate__accordion-toggle"><div class="c-faceplate__body"><div class="c-faceplate__company"><h1 class="c-faceplate__company-title"><p class="c-faceplate__company-title-small">Cours</p><a class="c-faceplate__company-link" href="/bourse/opcvm/cours/MP-803396/" title="Cours SG Oblig Corporate 1-3 I C">
SG Oblig Corporate 1-3 I C
</a></h1><div class="c-faceplate__info"><div class="c-faceplate__values"><div class="c-faceplate__price c-faceplate__price--inline"><span class="c-instrument c-instrument--last" data-ist-last>2 798.26</span><span class="c-faceplate__price-currency"> EUR</span></div><div class="c-faceplate__fluctuation c-faceplate__fluctuation--inline"><span class="u-color-stream-up"><span class="c-instrument c-instrument--variation" data-ist-variation>+0.02%</span></span>&nbsp;
</div></div></div><div class="c-faceplate__extra-info"><h2 class="c-faceplate__isin">FR0000448870 - Société Générale Gestion</h2><div class="c-faceplate__real-time">OPCVM dernier cours connu au 30/04/2019</div></div></div><div class="c-faceplate__chart"><div class="c-faceplate__chart-draw c-list-info--bottom-separator@sm-max c-list-info--top-separator@sm-max c-list-info--left-separator@md-min"><!-- MC Histogram ! --><div id="2002211046" class="c-chart c-chart--height-xs"
data-line-chart><div class="c-quote-chart__loader"><div class="c-loader-arrow c-loader-arrow--full-height"><img class="c-loader-arrow__img"

With this information you could try the following settings (which I have not verified):

url: https://www.boursorama.com/bourse/opcvm/cours/%1
Price: <header class="l-quotepage__header">.+data-ist-last>([\d, ]+\.\d+)</span>
Date: dernier cours connu au\ (.*)</div>
Date format: %d/%m/%y
Skip HTML stripping: marked

The price entry is a bit tricky, as the pattern data-ist-last>([\d, ]+\.\d+)</span> exists multiple times in the data but for other values and you need to pick the right one.

Looking forward to a report on your results.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
jmzorg
Registered Member
Posts
35
Karma
0

Re: Online quotes - regex

Mon May 06, 2019 7:55 am
I am using Boursorama with the following configurations :

[Online-Quote-Source-Boursorama]
CSVURL=
DateFormatRegex=%d %m %y
DateRegex=(\\d{2}\\/\\d{2}\\/\\d{4})
IDBy=0
IDRegex=%1
PriceRegex=faceplate__values\\D*(\\d{1} \\d{3}\\.\\d{2}|\\d+\\.\\d{2})
SkipStripping=true
URL=https://www.boursorama.com/bourse/opcvm/cours/%1

[Online-Quote-Source-Boursorama-actions]
CSVURL=
DateFormatRegex=%d %m %y
DateRegex=tradedate\\D*(\\d{1,2}\\.\\d{2}\\.\\d{2})
IDBy=0
IDRegex=%1
PriceRegex=faceplate__values\\D*(\\d{1} \\d+\\.\\d{2}|\\d+\\.\\d{2})
SkipStripping=true
URL=https://www.boursorama.com/cours/%1


By the way, the embedded KMyMoney Currency does not work anymore, i have an error each time i update stocks, can you have a look and see where is the problem ? i cannot do it by myself because i do not know what to look at in the currency page code.

[Online-Quote-Source-KMyMoney Currency]
CSVURL=
DateFormatRegex=%d/%m/%y
DateRegex=updated\\s\\d+:\\d+:\\d+\\(\\w+\\)\\s+(\\d{1,2}/\\d{2}/\\d{4})
IDBy=0
IDRegex=https://fx-rate.net/([^/]+/[^/]+)
PriceRegex=1[ a-zA-Z]+=</span><br\\s*/?>\\s*([,\\d+\\.]+)
SkipStripping=true
URL=https://fx-rate.net/%1/%2
jmzorg
Registered Member
Posts
35
Karma
0

Re: Online quotes - regex

Mon May 06, 2019 8:04 am
I just upload KMyMoney and the [Online-Quote-Source-KMyMoney Currency] works again, ;)
stephanesp
Registered Member
Posts
31
Karma
0

Re: Online quotes - regex

Tue May 28, 2019 6:32 am
Hi jmzorg and ipwizard,

Thanks for your replies. Based on those, I have used:

URL: https://www.boursorama.com/bourse/opcvm/cours/%1
Identified by: Identification number
Skip HTML stripping: ticked
Date format: %d.%m.%y

Then, I had to make a difference between trackers and OPCVM (hence created two templates):
Trackers:
Price: class="c-faceplate__price"><span class="c-instrument c-instrument--last" data-ist-last>([\d, ]+\.\d+)</span>
Date: Valeur liquidative au (.*) /

OPCVM:
Price: faceplate__price--inline"><span class="c-instrument c-instrument--last" data-ist-last>([\d, ]+\.\d+)</span>
Date: dernier cours connu au\ (.*)</div>

Steven


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], q.ignora, watchstar