使用Python的正则表达式模块re来提取url的值。以下是一个示例代码:

import re

script = '''
    ! function () {
        var ua = navigator.userAgent,
            img = new Image(),
            url = "https://manhua.acimg.cn/manhua_detail/0/02_19_50_4600f271d6a8277b324d056560cd6664_17631.jpg/0";
        if (ua.indexOf('MSIE 6.0') !== -1) {
            window.location.href = '/ComicView/showLowExplorerPage';
        }
        img.onload = function () {
            img.onload = null;
            img = null;
            window.loadedFirstPic = url;
        }
        img.src = url;
    }();
    window["no" + "nce"] = '' + '56bd8b5705d16bb2be5f65482dd11d7b';
'''

url = re.search(r'url = "(.*?)"', script).group(1)
print(url)

这会输出:https://manhua.acimg.cn/manhua_detail/0/02_19_50_4600f271d6a8277b324d056560cd6664_17631.jpg/0

这里使用了正则表达式url = "(.*?)"来匹配url的值,并使用.group(1)来获取第一个匹配项。


原文地址: https://www.cveoy.top/t/topic/pHuy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录