```python poem_response = requests.get(poem_url) poem_content = re.findall(r'<div class="contson" id="contson.*?>(.*?)</div>', poem_response.text, re.s)[0] poems.append((info[1], info[2], poem_content)) return poems # 爬取唐诗三百首 url = "https://so.gushiwen.cn/gushi/tangshi.aspx" poems = fetch_poems(url) # 保存到txt文件 with open("唐诗三百首.txt", "w", encoding="utf-8") as f: for poem in poems: f.write(f"{poem[0]} {poem[1]} {poem[2]} ") ``` [2024-06-23 11:07:39 | AI写代码神器 | 208点数解答]