import re
读取标题:
result = re.search(r'<title>(.*?)</title>', text, re.DOTALL)
result = re.search(r'<title>(.*?)</title>', text_without_newlines, re.DOTALL)
# 如果找到匹配项,则打印匹配内容
if result:
result_0 = re.sub(r'[a-zA-Z]','', result.group(1))
print(result_0.strip())
response = requests.get(url, headers=headers)
text=response.text
result = re.search(r'<title>(.*?)</title>', text, re.DOTALL)
if result:
name = result.group(1).strip()
name_1 = name.replace("\n", "").replace(" ","")
name_2 = re.sub(r'[a-zA-Z]','',name_1)
filename = rf'D:\1_pyproject\91file\{name_2}.mp4'