适配更新网站20260919
This commit is contained in:
1 parent
4f542e426b
commit
dd708be68e
1 file changed
+8
-18
@@ -24,35 +24,25 @@ class RoumanSite(BaseSite):
|
|||||||
tree = etree.HTML(html)
|
tree = etree.HTML(html)
|
||||||
image_urls_str = []
|
image_urls_str = []
|
||||||
json_all=""
|
json_all=""
|
||||||
|
img_prefix = [ ".jpg" , ".png" , ".webp"]
|
||||||
for data_json in tree.xpath('//script/text()'):
|
for data_json in tree.xpath('//script/text()'):
|
||||||
if str(data_json).startswith('self.__next_f.push([1,'):
|
if any(ext in data_json for ext in img_prefix):
|
||||||
data_json = data_json.replace('self.__next_f.push([1,', '')
|
|
||||||
data_json = data_json.replace('])', '')
|
|
||||||
data_json = data_json.replace('\\n', '')
|
data_json = data_json.replace('\\n', '')
|
||||||
data_json = data_json.replace('\\', '')
|
data_json = data_json.replace('\\', '')
|
||||||
if str(data_json).startswith('"'):
|
index_chapter = data_json.index('chapter:') + 8
|
||||||
data_json=data_json[1:]
|
index_cover = data_json.index('coverUrl:') - 9
|
||||||
if str(data_json).endswith('"'):
|
json_all = data_json[index_chapter:index_cover]
|
||||||
data_json=data_json[0:-1]
|
|
||||||
#if str(data_json).endswith('"') and not str(data_json).endswith('.jpg"') and not str(data_json).endswith('.webp"') and not str(data_json).endswith('ind\"'):
|
|
||||||
#if str(data_json).endswith('.jpg"') and not str(data_json).endswith('.webp"') and not str(data_json).endswith('ind\"'):
|
|
||||||
# data_json=data_json[0:-2]
|
|
||||||
json_all=json_all+data_json
|
|
||||||
#if "imageUrl" in json_all:
|
|
||||||
# image_urls_str = re.findall(r'"imageUrl":"(https?://[^"]+)"', json_all)
|
|
||||||
|
|
||||||
# 方法3:使用更精确的正则表达式,确保imageUrl和ind在同一对象中
|
# 方法3:使用更精确的正则表达式,确保imageUrl和ind在同一对象中
|
||||||
pattern_advanced = r'\{[^{}]*"imageUrl":"([^"]+)"[^{}]*"ind":(\d+)[^{}]*\}'
|
pattern_advanced = r'https://[^"\s]+?\.(?:jpe?g|png|webp)(?:[?#][^"\s]*)?'
|
||||||
matches_advanced = re.findall(pattern_advanced, json_all)
|
matches_advanced = re.findall(pattern_advanced, json_all)
|
||||||
# 检查图片数量是否完整
|
# 检查图片数量是否完整
|
||||||
if len(matches_advanced)-1 != int(matches_advanced[-1][1]) or len(matches_advanced) == 0:
|
if len(matches_advanced) == 0:
|
||||||
print(f"{chapter_url} \n图片数量不完整或为0")
|
print(f"{chapter_url} \n图片数量不完整或为0")
|
||||||
exit()
|
exit()
|
||||||
ver_count = 0
|
ver_count = 0
|
||||||
image_urls_str = []
|
image_urls_str = []
|
||||||
for image_url, ind in matches_advanced:
|
for image_url in matches_advanced:
|
||||||
if str(image_url).startswith("http") and image_url.split(".")[-1] in [ "jpg" , "png" , "webp"]:
|
if str(image_url).startswith("http") and image_url.split(".")[-1] in [ "jpg" , "png" , "webp"]:
|
||||||
#print(f"imageUrl: {image_url}, ind: {ind}")
|
|
||||||
image_urls_str.append(image_url)
|
image_urls_str.append(image_url)
|
||||||
ver_count += 1
|
ver_count += 1
|
||||||
if ver_count != len(matches_advanced):
|
if ver_count != len(matches_advanced):
|
||||||
|
|||||||
Reference in new issue
Block a user