采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
my_str = ‘’’
‘’’
re.findall(‘url +=(.*)’,my_str)
我没太懂你的意思,你是要多行匹配吗?正则表达式默认匹配到换行符就不往后匹配了 dotall = re.compile(pattern, re.DOTALL)
<meta content="always" name="referrer"> <script> (new Image()).src = 'https://weixin.sogou.com/approve?uuid=' + 'fa19aa76-3477-4f63-81a7-e1ab927efe4a' + '&token=' + '5ACCCF0F96457F48E6E2246189745BFAE702D56160A63434' + '&from=inner'; setTimeout(function () { var url = ''; url += 'http://mp.w'; url += 'eixin.qq.co'; url += 'm/s?src=11&'; url += 'timestamp=1'; url += '621505034&v'; url += 'er=3080&sig'; url += 'nature=66kE'; url += '3FmQ04OFZvV'; url += 'iIEe0kzfug2'; url += 'AFp7HCryJI8'; url += 'cF31uhAqprwIHQARrwnOlWWXggOPaN8RBpOQFRO19NMem7SDGtgNsgOnaDjZRt8ew*YbNbCPA30mkk-k33skmkP6UC5&new=1'; url.replace("@", ""); window.location.replace(url) },100); </script> 我就是要提取这段文本的url,但是他是拼接的,我搞了好久了。。。
这种问题只有自己通过正则表达式提取,或者使用python调用js的执行引擎执行这段逻辑拿到返回值
my_str
=
'''
<meta content="always" name="referrer">
<script>
(new Image()).src = 'https://weixin.sogou.com/approve?uuid=' + 'fa19aa76-3477-4f63-81a7-e1ab927efe4a' + '&token=' + '5ACCCF0F96457F48E6E2246189745BFAE702D56160A63434' + '&from=inner';
setTimeout(function () {
var url = '';
url += 'http://mp.w';
url += 'eixin.qq.co';
url += 'm/s?src=11&';
url += 'timestamp=1';
url += '621505034&v';
url += 'er=3080&sig';
url += 'nature=66kE';
url += '3FmQ04OFZvV';
url += 'iIEe0kzfug2';
url += 'AFp7HCryJI8';
url += 'cF31uhAqprwIHQARrwnOlWWXggOPaN8RBpOQFRO19NMem7SDGtgNsgOnaDjZRt8ew*YbNbCPA30mkk-k33skmkP6UC5&new=1';
url.replace("@", "");
window.location.replace(url)
},100);
</script>
登录后可查看更多问答,登录/注册
带你彻底掌握Scrapy,用Django+Elasticsearch搭建搜索引擎
4.9k 30
2.6k 18
1.3k 18
1.5k 15
3.0k 15
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号