🐛 Fixed percentage number
|
@ -31,7 +31,10 @@ with db_session:
|
||||||
if i["props"]:
|
if i["props"]:
|
||||||
|
|
||||||
def replace_props(m):
|
def replace_props(m):
|
||||||
result = i["props"][m.group(1)]
|
prop_name = m.group(1)
|
||||||
|
result = i["props"][prop_name]
|
||||||
|
if prop_name.startswith("prct"):
|
||||||
|
result = int(result * 100)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
result = result[0]
|
result = result[0]
|
||||||
if not isinstance(result, str):
|
if not isinstance(result, str):
|
||||||
|
|
|
@ -35,6 +35,8 @@ with db_session:
|
||||||
if prop_name == "ShockAffectDuration":
|
if prop_name == "ShockAffectDuration":
|
||||||
prop_name = "duration" # 雷盾带电手动触发
|
prop_name = "duration" # 雷盾带电手动触发
|
||||||
result = i["props"][prop_name]
|
result = i["props"][prop_name]
|
||||||
|
if prop_name.startswith("prct"):
|
||||||
|
result = int(result * 100)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
result = result[0]
|
result = result[0]
|
||||||
if not isinstance(result, str):
|
if not isinstance(result, str):
|
||||||
|
|
|
@ -35,6 +35,8 @@ with db_session:
|
||||||
if prop_name == "ShockAffectDuration":
|
if prop_name == "ShockAffectDuration":
|
||||||
prop_name = "duration2" # 雷盾带电手动触发
|
prop_name = "duration2" # 雷盾带电手动触发
|
||||||
result = i["props"][prop_name]
|
result = i["props"][prop_name]
|
||||||
|
if prop_name.startswith("prct"):
|
||||||
|
result = int(result * 100)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
result = result[0]
|
result = result[0]
|
||||||
if not isinstance(result, str):
|
if not isinstance(result, str):
|
||||||
|
|
|
@ -19,10 +19,16 @@ class OutfitSpider(scrapy.Spider):
|
||||||
def parse(self, response):
|
def parse(self, response):
|
||||||
for quote in response.css(".wikitable tbody tr"):
|
for quote in response.css(".wikitable tbody tr"):
|
||||||
name_en = quote.css("td:nth-child(2) > span:last-child::text").get()
|
name_en = quote.css("td:nth-child(2) > span:last-child::text").get()
|
||||||
preview = quote.css("td:nth-child(6) a::attr('href')").get()
|
|
||||||
if not name_en:
|
if not name_en:
|
||||||
|
print(name_en)
|
||||||
continue
|
continue
|
||||||
|
preview = quote.css(
|
||||||
|
"td:nth-child(6) > span:last-child a::attr('href')"
|
||||||
|
).get()
|
||||||
|
try:
|
||||||
r = requests.get(preview)
|
r = requests.get(preview)
|
||||||
with db_session:
|
with db_session:
|
||||||
w = Outfit.select(name_en=name_en).first()
|
w = Outfit.select(name_en=name_en).first()
|
||||||
w.preview = io.BytesIO(r.content).getbuffer().tobytes()
|
w.preview = io.BytesIO(r.content).getbuffer().tobytes()
|
||||||
|
except:
|
||||||
|
print("Preview not available.")
|
||||||
|
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 60 KiB |