day21 作业
获取新闻的链接与名字并交换位置
import requests
import re
resp = requests.get('https://www.sohu.com/')
re_str = re.compile(r'href="(.+?)".+title="(.+?)"')
movie_title = re_str.findall(resp.text)
for x in movie_title:
print(f'<{x[1]}{x[0]}>')
with open('id.txt', 'w', encoding='utf-8') as f:
f.write(str(movie_title))