使用XPATH隔离内联javascript [英] Using XPATH to isolate inline javascript

查看:81
本文介绍了使用XPATH隔离内联javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提取在数千个URL上唯一不同的内联javascript,并嵌套在不同级别的代码中。

I'm trying to extract inline javascript that is uniquely different on thousands of URLs, and is nested within the code at various levels.

我熟悉自己XPATH语法我试图看看是否有人知道一个很好的方法来定位javascript例如:

As I familiarize myself with XPATH syntax I am trying to see if anyone knows a good way to target 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>

< script> ... data_n中唯一唯一的标识符。 ..< / script> 我试图提取它包含:

var tabsRelated = ...

在XPATH的范围内有没有人知道一种方式找到包含该变量的脚本并定位整个脚本?排序类似:

Within the confines of XPATH does anyone know a way to find the script that contains that variable and target the entire script? Sorta like:

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

语法不正确

推荐答案

使用

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

其中 $ someDistinguishingValue 应该是替换为相应的值(例如,上面的XPath表达式可以作为字符串动态生成,然后使用可用的XPath API将此字符串计算为XPath表达式(例如DOM方法 SelectNodes ())。

where $someDistinguishingValue should be replaced with the corresponding value (for example the above XPath expression may be dynamically generated as a string and then this string evaluated as an XPath expression using the available XPath API (such as the DOM method SelectNodes() ).

这篇关于使用XPATH隔离内联javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆