当前位置:网站首页>RE 匹配pdf URL地址

RE 匹配pdf URL地址

2020-11-10 15:10:32 wyh草样

import re
str = """
    <script language='javascript' type="f9d183f87da800c789dfdf6d-text/javascript">location.href='https://www.agialpress.com/articles/cellular-mechanisms
-of-oestrogen-in-breast-cancer-development.pdf';</script><script src="https://ajax.cloudflare.com/cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.js" 
data-cf-settings="f9d183f87da800c789dfdf6d-|49" defer=""></script>

"""

regular = re.findall('(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+pdf)|([a-zA-Z]+.\w+\.+[a-zA-Z0-9\/_]+pdf)',str)

如果是匹配url地址则用

regular = re.findall(r"(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)|([a-zA-Z]+.\w+\.+[a-zA-Z0-9\/_]+$)",str)

版权声明
本文为[wyh草样]所创,转载请带上原文链接,感谢
https://www.cnblogs.com/wyh0923/p/13953856.html