Please read the question carefully first.
I have tried so many commands to retrieve one variable from the server [TSE] (https://old.tsetmc.com/Loader.aspx?ParTree=15131F) (It serves Stock Exchange information). This page is a JavaScript playground that uses Filters and the filters are available in the cache to view by pressing the F12, entering the console, pasting the command
JSON.parse( localStorage.MarketWatchSettings)['Filters']
, accepting the consequences and viewing the codes but the page has a text field that allows you to write the codes as soon as you get in.
The variable is *(l18)* and represents the company name. As you know this kinda server is not open to users and it can only deliver the information you want.
The question is clearly: how can I allocate a number to the company name that is available in a list that I prepared to be able to make a link from that very server opening with [text](http://www.tsetmc.com/InstInfo) and contiuning with a set of number such as [text](http://www.tsetmc.com/InstInfo/25244329144808274) for the biggest company named "Fars"?
The list is so long and I shortened it to a preview for you:
const StockCodes = {
آبادا: [37661500521100963],
آپ: [55254206302462116],
آسيا: [51106317433079213],
};
We need to match the (l18) string (that is retrieved live) to the keys in constant above and use the value (number) in front of it. Later then umber is used to complete the link http://www.tsetmc.com/InstInfo and make a new link such as http://www.tsetmc.com/InstInfo/37661500521100963.
I tried some solutions and here's three of them:
1.*Constant itself*:
var Names = StockCodes.(l18)
var url = String.fromCodePoint(StockCodes);
var finalLink = "http://www.tsetmc.com/InstInfo/"+url
console.log(finalLink)
2. *Includes*:
var Names = StockCodes.(l18)
if (StockCodes.includes((l18)))
{var finalLink ="http://www.tsetmc.com/InstInfo/"+Names}
console.log(finalLink)
3. *Match*:
let resultofsearch = StockCodes.match((l18));
var TSEPage = TSEPageCode(StockCodes.resultofsearch)
var finalLink = "http://www.tsetmc.com/InstInfo/"+TSEPage
console.log(finalLink)
The
(l18)
represents a name (the company name) in words (letters and sometimes letters with numbers but opening with letters) and sometimes has white space too.
A big problem with the strings like this is the parentheses. You cannot use them after the dots to call rows. The other question that is raises under this question is How can I solve this problem when the server dictates that the string starts and ends with the parentheses such as `"(tmin)"` for lowest price?
We cant use: "...StockCodes.(l18)"
within the code (it pushes an error:
TypeError:StockCodes.row is undefined
All of the codes in one place:
var companyname = (l18) && (l18) = "آبادا"
const StockCodes = {
آبادا: [37661500521100963],
آپ: [55254206302462116],
آسيا: [51106317433079213],
};
var Names = StockCodes.(l18)
var url = String.fromCodePoint(StockCodes);
var finalLink = "http://www.tsetmc.com/InstInfo/"+url
console.log(finalLink)
var Names = StockCodes.(l18)
if (StockCodes.includes((l18)))
{var finalLink ="http://www.tsetmc.com/InstInfo/"+Names}
console.log(finalLink)
let resultofsearch = StockCodes.match((l18));
var TSEPage = TSEPageCode(StockCodes.resultofsearch)
var finalLink = "http://www.tsetmc.com/InstInfo/"+TSEPage
console.log(finalLink)