Update getdata.py

master
p2tfsuw8f 3 years ago
parent 8b7b133be7
commit fcfa3da2e4

@ -10,4 +10,15 @@ response.encoding = 'utf-8'
html = response.text html = response.text
soup = BeautifulSoup(html, 'html.parser') soup = BeautifulSoup(html, 'html.parser')
ans = soup.select('div.rich_media > div.rich_media_inner ') ans = soup.select('div.rich_media > div.rich_media_inner ')
ans1 = ans[0].text.encode() ans1 = ans[0].text.encode()
def openreadtxt(file_name):
data = []
file = open(file_name, 'r', encoding='utf-8') # 打开文件
file_data = file.readlines() # 读取所有行
for row in file_data:
tmp_list = row.split(' ') # 按‘,’切分每行的数据
tmp_list[-1] = tmp_list[-1].replace('\n', '') # 去掉换行符
data.append(tmp_list) # 将每行数据插入data中
file.close()
return data
Loading…
Cancel
Save