扫码关注官方订阅号
sample:
我想获取http://xxx.com/a.html 请问如何写正则表达式
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
/<a[^>]*href="([^"]+)"[^>]*>/
from bs4 import BeautifulSoup
soup = BeautifulSoup(sample)
url = soup.find('a').get('href')
这还不简单
text = '<a rpos="" cpos="title" href="http://xxx.com/a.html" style="font-family:Arial,SimSun,sans-serif;font-size:16px;color:#0000cc; text-decoration:none;" target="_blank">' urlPattern = r'(href="http://[\s\S]+.html")' pattern = re.compile(urlPattern) match = re.findall(pattern,text,0)
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
from bs4 import BeautifulSoup
soup = BeautifulSoup(sample)
url = soup.find('a').get('href')
这还不简单