|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
<script>;var chapterImages = ["\/UploadFiles\/9805\/2016516354383.jpg","\/UploadFiles\/9805\/2016516354389.jpg","\/UploadFiles\/9805\/2016516354610.jpg","\/UploadFiles\/9805\/2016516355407.jpg","\/UploadFiles\/9805\/2016516356374.jpg","\/UploadFiles\/9805\/2016516357502.jpg","\/UploadFiles\/9805\/2016516357280.jpg","\/UploadFiles\/9805\/2016516358302.jpg","\/UploadFiles\/9805\/2016516359662.jpg","\/UploadFiles\/9805\/201651640180.jpg","\/UploadFiles\/9805\/201651640851.jpg","\/UploadFiles\/9805\/201651641984.jpg","\/UploadFiles\/9805\/201651642783.jpg","\/UploadFiles\/9805\/201651643139.jpg","\/UploadFiles\/9805\/201651644320.jpg","\/UploadFiles\/9805\/201651645795.jpg","\/UploadFiles\/9805\/201651645798.jpg","\/UploadFiles\/9805\/201651646595.jpg","\/UploadFiles\/9805\/201651646696.jpg","\/UploadFiles\/9805\/201651647616.jpg","\/UploadFiles\/9805\/201651647381.jpg","\/UploadFiles\/9805\/201651648121.jpg","\/UploadFiles\/9805\/201651649249.jpg","\/UploadFiles\/9805\/2016516410732.jpg","\/UploadFiles\/9805\/2016516411302.jpg","\/UploadFiles\/9805\/2016516411868.jpg","\/UploadFiles\/9805\/2016516412715.jpg","\/UploadFiles\/9805\/2016516412141.jpg","\/UploadFiles\/9805\/2016516413846.jpg","\/UploadFiles\/9805\/2016516414979.jpg","\/UploadFiles\/9805\/2016516415661.jpg","\/UploadFiles\/9805\/2016516417536.jpg","\/UploadFiles\/9805\/2016516418439.jpg","\/UploadFiles\/9805\/2016516420326.jpg","\/UploadFiles\/9805\/2016516421689.jpg","\/UploadFiles\/9805\/2016516421563.jpg","\/UploadFiles\/9805\/2016516422817.jpg","\/UploadFiles\/9805\/2016516423274.jpg","\/UploadFiles\/9805\/2016516423149.jpg","\/UploadFiles\/9805\/2016516424127.jpg","\/UploadFiles\/9805\/2016516424912.jpg","\/UploadFiles\/9805\/2016516425372.jpg","\/UploadFiles\/9805\/2016516425813.jpg","\/UploadFiles\/9805\/2016516426169.jpg","\/UploadFiles\/9805\/2016516426388.jpg","\/UploadFiles\/9805\/2016516427746.jpg"];var chapterPath = "";</script>
有以上代码,我虽然能匹配出来,但是没能达到我的要求
我的要求是:我只要列表里面的的东西
比如:list[0] = "\/UploadFiles\/9805\/2016516354383.jpg"
以此类推
求各位大佬解答
本帖最后由 suchocolate 于 2021-3-28 11:07 编辑
第一种思路:整体获取转成列表。 import re
txt = '''<script>;var chapterImages = ["\/UploadFiles\/9805\/2016516354383.jpg","\/UploadFiles\/9805\/2016516354389.jpg","\/UploadFiles\/9805\/2016516354610.jpg","\/UploadFiles\/9805\/2016516355407.jpg","\/UploadFiles\/9805\/2016516356374.jpg","\/UploadFiles\/9805\/2016516357502.jpg","\/UploadFiles\/9805\/2016516357280.jpg","\/UploadFiles\/9805\/2016516358302.jpg","\/UploadFiles\/9805\/2016516359662.jpg","\/UploadFiles\/9805\/201651640180.jpg","\/UploadFiles\/9805\/201651640851.jpg","\/UploadFiles\/9805\/201651641984.jpg","\/UploadFiles\/9805\/201651642783.jpg","\/UploadFiles\/9805\/201651643139.jpg","\/UploadFiles\/9805\/201651644320.jpg","\/UploadFiles\/9805\/201651645795.jpg","\/UploadFiles\/9805\/201651645798.jpg","\/UploadFiles\/9805\/201651646595.jpg","\/UploadFiles\/9805\/201651646696.jpg","\/UploadFiles\/9805\/201651647616.jpg","\/UploadFiles\/9805\/201651647381.jpg","\/UploadFiles\/9805\/201651648121.jpg","\/UploadFiles\/9805\/201651649249.jpg","\/UploadFiles\/9805\/2016516410732.jpg","\/UploadFiles\/9805\/2016516411302.jpg","\/UploadFiles\/9805\/2016516411868.jpg","\/UploadFiles\/9805\/2016516412715.jpg","\/UploadFiles\/9805\/2016516412141.jpg","\/UploadFiles\/9805\/2016516413846.jpg","\/UploadFiles\/9805\/2016516414979.jpg","\/UploadFiles\/9805\/2016516415661.jpg","\/UploadFiles\/9805\/2016516417536.jpg","\/UploadFiles\/9805\/2016516418439.jpg","\/UploadFiles\/9805\/2016516420326.jpg","\/UploadFiles\/9805\/2016516421689.jpg","\/UploadFiles\/9805\/2016516421563.jpg","\/UploadFiles\/9805\/2016516422817.jpg","\/UploadFiles\/9805\/2016516423274.jpg","\/UploadFiles\/9805\/2016516423149.jpg","\/UploadFiles\/9805\/2016516424127.jpg","\/UploadFiles\/9805\/2016516424912.jpg","\/UploadFiles\/9805\/2016516425372.jpg","\/UploadFiles\/9805\/2016516425813.jpg","\/UploadFiles\/9805\/2016516426169.jpg","\/UploadFiles\/9805\/2016516426388.jpg","\/UploadFiles\/9805\/2016516427746.jpg"];var chapterPath = "";</script>'''
result = re.findall(r'\[.*?\]', txt) # 获取方括号和其中的内容,.*?非贪婪模糊匹配。
result = eval(result[0]) # 以字符串作为命令执行,相当于直接用字符串创建列表。
for item in result:
print(item)
第二种思路:逐个jpg匹配,每jpg特点是.jpg结尾,外层有双引号。 result = re.findall(r'"(.*?\.jpg)"', txt) # 非贪婪模糊匹配,以.jpg结尾,且外层有双引号的内容,()只打印组内的内容,外部的其他内容,包括双引号不打印。
for item in result:
print(item)
|
|