I may have come upon something:
First an explanation:
I want to get information from a website without subscribing to a service. I use a browser with the appropriate url to get the page containing the data I need. This is an asynchronous process.
I defined a class GetShareQuote where a browser is created and where a function CheckShareQuote() is provided to generate a url and load it into the browser. The event OnDocumentLoaded allows to access the page and it fills in the data elements provided in the call to that function. If relevant, a call using arrays is used, and successive urls are generated and loaded to obtain data pertinent to these urls. When all the elements are filled (a set per url) the process stops.
GetShareQuote is created in the application, and the function CheckShareQuote() is called with the relevant data. A timer is launched to check whether values were obtained in GetShareQuote. When all the expected values have been retrieved the process in the application sequence terminates.
One last comment : this works fine under Windows and OSX.
Code:
1. Application sequence:
...
GSQ = new GetShareQuote(this);
// single url
GSQ->CheckShareQuote(titre, isin, "e, &devise, "eDate, &dQuote, &errMessage);
// multiple urls
// GSQ->CheckShareQuote(&titres, &isins, "es, &devises, "eDates, &dQuotes, &errMessage);
timerShareQuotes.SetOwner(this, ID_TimerShareQuotesRPF);
timerShareQuotes.StartOnce(timerShareQuoteInterval);
...
void OnTimerShareQuote()
{ // check if all data has been retrieved
}
2. Class GetShareQuote:
void GetShareQuote::CreateControls()
{
////@begin GetShareQuote content construction
// Generated by DialogBlocks, Mon 10 Feb 2020 11:46:33 CET (unregistered)
GetShareQuote* itemFrame1 = this;
////@end GetShareQuote content construction
m_browser = wxWebView::New(this, wxID_ANY,wxEmptyString);
m_browser->Connect(m_browser->GetId(), wxEVT_WEBVIEW_LOADED, wxWebViewEventHandler(GetShareQuote::OnDocumentLoaded), NULL, this);
}
bool GetShareQuote::CheckShareQuote(wxString Titre, wxString CodeIsin, wxString* Quote, wxString* Devise, wxString* QuoteDate, wxString* ErrMessage)
{ // keep different from download for clarity
m_titre = Titre;
m_codeISIN = CodeIsin;
m_quote = Quote;
m_devise = Devise;
m_dateQuote = QuoteDate;
m_errMessage = ErrMessage;
m_errMessage->Clear();
m_numberOfShares = 1;
url = BuildUrl(m_titre,m_codeISIN);
m_browser->LoadURL(url);
return true;
}
void GetShareQuote::OnDocumentLoaded(wxWebViewEvent& event)
{ // here the loaded page is processed and the value retrieved.
// If several urls are present, they are loaded in the browser succesively
// and processed here.
// procedd page loaded
item++;
if (item < m_numberOfShares)
{ // multiple urls - next url
url = BuildUrl(m_titres->Item(item).Lower(), m_codesISIN->Item(item));
m_browser->LoadURL(url);
}
}
3. Debugger
The url is printed below at the first break at line 166 (the url is generated in line 162 and used in line 164).
further down the url is damaged: see console messages.
That may be the reason why the applications fails.
Starting program: /home/raanan/Documents/AccountsManager2/GTKDebug/AccountsManager
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe3684700 (LWP 15105)]
[New Thread 0x7fffa2d61700 (LWP 15106)]
[New Thread 0x7fffa13b2700 (LWP 15107)]
[New Thread 0x7fffa0bb1700 (LWP 15108)]
[New Thread 0x7fff91a4a700 (LWP 15109)]
[New Thread 0x7fff90c44700 (LWP 15110)]
Thread 1 "AccountsManager" hit Breakpoint 3, GetShareQuote::CheckShareQuote (
this=0x5555566e8020, Titres=0x55555698ec18, CodesISIN=0x55555698ec40,
Quotes=0x55555698ec68, Devises=0x55555698ec90, QuoteDates=0x55555698ecb8,
DQuotes=0x55555698ece0, ErrMessage=0x55555698eb68)
at getsharequote.cpp:166
166 return true;
(gdb) p url
$1 = {static npos = 18446744073709551615,
m_impl = L"https://www.boursier.com/actions/cours/ ... 04,FR.html", m_convertedToChar = {
m_str = 0x5555569c3da0 "https://www.boursier.com/actions/cours/ ... 04,FR.html", m_len = 71}}
(gdb) c
Continuing.
[New Thread 0x7fff8bbf2700 (LWP 15116)]
[New Thread 0x7fff89c09700 (LWP 15117)]
[New Thread 0x7fff89408700 (LWP 15118)]
[New Thread 0x7fff88c07700 (LWP 15119)]
[New Thread 0x7fff7ffff700 (LWP 15120)]
[New Thread 0x7fff7f7fe700 (LWP 15121)]
[New Thread 0x7fff7effd700 (LWP 15122)]
[New Thread 0x7fff7e7fc700 (LWP 15123)]
[New Thread 0x7fff7dffb700 (LWP 15124)]
[New Thread 0x7fff7d05b700 (LWP 15125)]
** Message: 11:50:34.994: console message:
https://www.boursier.com/Scripts/js/bot ... 26SmOUqHQ1 @37791: SyntaxError: Unexpected identifier 'isDown'
[Thread 0x7fff8bbf2700 (LWP 15116) exited]
[Thread 0x7fff7e7fc700 (LWP 15123) exited]
[Thread 0x7fff7ffff700 (LWP 15120) exited]
[Thread 0x7fff88c07700 (LWP 15119) exited]
[Thread 0x7fff7effd700 (LWP 15122) exited]
[Thread 0x7fff7f7fe700 (LWP 15121) exited]
[Thread 0x7fff7dffb700 (LWP 15124) exited]
[Thread 0x7fff89408700 (LWP 15118) exited]
** Message: 11:50:36.729: console message:
https://www.boursier.com/actions/cours/ ... 04,FR.html @846: TypeError: undefined is not a function (evaluating '$('.bmodaal').modaal({
'width' : 600,
'custom_class': 'buy-sell--modaal'
})')
130 ../sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: No such file or directory.
Thread 1 "AccountsManager" received signal SIGSEGV, Segmentation fault.
____longjmp_chk () at ../sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S:130
(gdb)