首页 > 解决方案 > 有没有办法搜索搜索所有字符(包括“<”字符)的字符串?

问题描述

我会尽量具体一点。我尝试使用 ..text.content 和 ..innerhtml 并且在搜索时似乎都缺少“<”字符。在下面搜索这个总字符串时,看不到它。

这就是我在特定的 html 页面上搜索的内容。

'''

    '231-8&quot;},&quot;availability_html&quot;:&quot;&lt;p class=\&quot;stock out-of-stock'

''' 这是我的代码...

    'if ('
    'document.documentElement.textContent.search('231-8&quot;},&quot;availability_html&quot;:&quot;&lt;p class=\&quot;stock out-of-stock') != -1)'
    '{'
    'alert("FOUND!");'
    '} else {'
    'alert("NOT FOUND!");'
    '}' 

''' 我可以搜索字符串的第一部分一直到 "<" 部分,它工作正常。

我究竟做错了什么?

标签: innerhtml

解决方案


这是我的解决方案,我想通了...

    '231-8&quot;},&quot;availability_html&quot;:&quot;<p class=\\\\&quot;stock out-of-stock

推荐阅读