# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
def second_pro(text):
last_sen = []
while 1:
last_sen.append(text.split(",")[-1])
other_list = text.split(",")[:-1]
# 特定位置超长,需要处理
if len(other_list) == 1:
last_sen.append(other_list[0].split(",")[-1])
other_list = other_list[0].split(",")[:-1]
if len(",".join(other_list)) < 508:
return ",".join(other_list), last_sen
text = ",".join(other_list[:-1])
def maching(text):
hold_l = []
con_text = []
for one in text.split(","):
hold_l.append(one)
if len(",".join(hold_l)) > 508:
model_text, last_sen = second_pro(",".join(hold_l))
hold_l = []
hold_l.append(",".join(last_sen))
con_text.append(model_
Python爬取网页文本内容
最新推荐文章于 2024-04-27 16:08:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)