url match

videoUrlMatch = re.search(r"Real URLs:\s*(?P<videoUrls>.*){}".format(os.linesep), parseResult, re.DOTALL | re.IGNORECASE).group('videoUrls').split()  # 搜寻链接,因为有了download-url:,所以必须从Real URLs:后面搜寻
            # print(re.search(r"Real URLs:\s*(?P<videoUrls>.*){}".format(os.linesep), parseResult, re.DOTALL | re.IGNORECASE).group('videoUrls'),videoUrlMatch)
        

videoUrlMatch = re.findall(r'''Real URLs?:\s*[\[']*(?P<videoUrls>http.*?)['\]]*\s+''', parseResult, re.IGNORECASE)



videoUrlMatch = re.findall(r'''Real URLs?:#you-get解析爱奇艺显示Real URL,解析搜狐显示Real URLs,ykdl则是Real urls
                                    \s*#匹配换行和空格
                                    [\[']*#匹配you-get解析爱课程、爱奇艺的字符化列表左边[',用括号([')*的话findall会得出不相干的结果,故而不用
                                    (?P<videoUrls>http.*?)#匹配url,非贪婪模式以便不匹配出多余空格和不匹配结尾的字符化列表右边']
                                    ['\]]*#匹配you-get解析爱课程、爱奇艺的字符化列表右边']
                                    \s+''', #url的结尾都是换行,必须有
                                    parseResult, re.IGNORECASE| re.VERBOSE)  # 搜寻链接,因为有了download-url:,所以必须从Real URLs:后面搜寻



>>> re.findall(r'''Real URLs?:\s*[\[']*(?P<videoUrls>http://\S*)['\]]*''', parseResult, re.IGNORECASE|re.DOTALL)
['http://39.130.134.23:80/199/2/78/letv-uts/14/ver_00_22-1053883476-avc-2999799-aac-128000-2820200-1106779568-60506e98dba03609f162c0a1319f8365-1467722446828_mp4/ver_00_22_0_0_1_518316_0_0.ts?mltag=100&platid=1&splatid=101&playid=0&geo=CN-25-353-4&tag=letv&ch=&p1=&p2=&p3=&tss=ios&b=3139&bf=52&nlh=4096&path=&sign=letv&proxy=3702879625,1728279117,3719677991&uuid=&ntm=1491493200&keyitem=GOw_33YJAAbXYE-cnQwpfLlv_b2zAkYctFVqe5bsXQpaGNn3T1-vhw..&its=0&nkey2=8df56d0d2d11ae422e5abf18d684822f&uid=1971868906.rp&qos=3&enckit=&m3v=1&token=&vid=&liveid=&station=&app_name=&app_ver=&fcheck=0&pantm=&panuid=&pantoken=&cips=117.136.84.234&vod_live_path=&ledituid=&leditcid=&leditcip=&leditfl=&leditafl=&ajax=&lsbv=']
>>> 

对于多行url只能match Real URL后面第一个,所以后面采用了去掉Real URL的match regex

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值