Using XPATH to isolate inline javascript

I am trying to extract inline javascript that is uniquely different across thousands of URLs and nested in code at different levels.

As I get to know the XPATH syntax, I'm trying to figure out if anyone knows a good way to configure javascript. For example:

<script type="text/javascript"> ...data_#...</script>
<script type="text/javascript"> ...data_#...</script>
<script type="text/javascript"> ...data_n...</script>
<script type="text/javascript"> ...data_#...</script>
<script type="text/javascript"> ...data_#...</script>

The only unique identifier inside <script>...data_n...</script>that I am trying to extract contains:

var tabsRelated = ...

Within XPATH, does anyone know a way to find a script that contains this variable and targets the whole script? Varieties like:

//script[inner.text contains='var tabsRelated'
Syntax

wrong

+1
source share
1 answer

Using

//script[contains(., $someDistinguishingValue)]

, $someDistinguishingValue (, XPath , XPath API XPath ( DOM SelectNodes()).

+4

Source: https://habr.com/ru/post/1614318/


All Articles