酷代码 AI
菜单
服务商

Python爬取唐诗三百首,领略经典诗词魅力!

ontentdiv") poems = [] for div in content_divs: title = div.find('p', class_="cont") author = div.find('p', class_="source") poem = div.find('div', class_="contson") if title and author and poem: poems.append({ "title": title.text.strip(), "author": author.text.strip(), "content": poem.text.strip() }) return poems else: return None # 打印爬取结果 poems = scrape_data() for poem in poems: print(poem["title"]) print(poem["author"]) print(poem["content"]) print() ######[AI写代码神器 | 443点数解答 | 2024-06-24 01:16:00]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]