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() [2024-06-24 01:16:00 | GPT-代码助手 | 443字解答]