VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > python入门教程 >
  • RE 匹配pdf URL地址

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



相关教程