我想要一个用于 python 的正则表达式来检测 URL 链接是否有效。它应该检测“/”和“?”之间的数字 前 5 位数字为“17110”,后 2 位数字为“01”,并且必须有 7 位数字。例如,mainsoup = BeautifulSoup(await r.text(),features="html.parser")for link in mainsoup.find_all('a'), print(link.get('href')) #/announcement/171103301?user_id=0&lang=2&phone_type=0 #/announcement/171103501?user_id=0&lang=2&phone_type=0 #/announcement/171101401?user_id=0&lang=2&phone_type=0 #/announcement/60110100005108?user_id=0&lang=2&phone_type=0 #/announcement/60110100005300?user_id=0&lang=2&phone_type=0 #/announcement/1910064?user_id=0&lang=2&phone_type=0 #/announcement/171201811?user_id=0&lang=2&phone_type=0 #placing links into a list #regex to get first 3 links as valid
添加回答
举报
0/150
提交
取消