[Python] 纯文本查看 复制代码from bs4 import BeautifulSoup
import requests
import json
import re
import time
def get_one_page(url):
try:
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
response.encoding = "UTF-8"
return response.text
except requests.ConnectionError:
return None
def choice_jiekou(): # 抓取每个风格的地址
URL = "https://www.gushiwen.org/shiju/xiejing.aspx"
html = requests.get(URL).text
soup = BeautifulSoup(html, 'lxml')
gushi_1 = soup.find_all("div", {"class":"cont"})
raws = []
for gushi in gushi_1:
gushi = gushi.fin