1 respone = requests.get('https://www.meiwen.com.cn/article/58030.html') 2 #解析获取到的网页信息 3 result_list = BeautifulSoup(respone.text,'lxml') 4 #在解析的信息中查找p标签, 5 soup = result_list.select('p') 6 #将soup列表转换为文本格式,并且保存到txt文件中 7 for result in soup: 8 res = result.text 9 # print(res) 10 with open('D:downloadmeiwen.txt', 'a',encoding='utf-8') as file: 11 file.write(res) 12 print('success') 13