There is a page from which you need to get what is displayed on the screen, namely, in the attribute with the class hover_item_name .

enter image description here

I use the usual XMLHttpRequest(); but he prints nothing.

It turns out that all data is stored in js at the bottom of the page.

Did not invent...

I am only interested in the selected array fragment:

Also did not come up with ...

How to get this "Element"?

  • Are you writing an extension in a browser? This is me to the fact that the tag "chrome-extension" is present here. - Visman
  • Yes. I thought maybe some functions are for this in the chrome api. - Slavik Okara
  • What is stopping you from parsing the contents of the script tag? - Petr Abdulin
  • It hinders the fact that I do not know how. Please help! - Slavik Okara

2 answers 2

The easiest option is to parse the contents in this situation to me through the use of regular expressions , since essentially it is one big line. And due to the fact that you know the key of the desired parameter in advance, it can be done quite simply with the following regular expression:

 /"market_hash_name":"(.*?)"/ 

The required substring must begin with "market_hash_name":" and end " , while we want to separately capture what is inside the quotation marks, what can be done with (.*?) Where . - any character, * - repeated any number of times ? - the search will be executed before the first " double quote, ie in the" non-greedy mode "(otherwise it will work until the very last quote in the entire line).

 // предположим, что переменная scriptTag - DOM элемент того самого скрипта // получаем его содержимое в качестве строки var content = scriptTag.innerHTML; var pattern = /"market_hash_name":"(.*?)"/; var match = content.match(pattern); // под индексом 0 будет храниться результат всего выражения // под индексом 1 - результат захватывающей группы (.*?) var name = match[1]; console.log(name); // "P90 | Fallout Warning (Field-Tested)" 

A live example is here: http://jsbin.com/faposoteci/edit?html,js,console

  • Thank you very much ! Separately, thank you for the description of the process! - Slavik Okara

We write javascript parser using Google Chrome Extension , read how to make a parser.

  • How to parse the page - I know. But how to parse the contents of the script tag - Slavik Okara