🐛 Fixed percentage number

This commit is contained in:
zhbaor 2022-10-13 17:35:47 +08:00
parent 1d0797a58a
commit 7cef2f75f9
10 changed files with 19 additions and 6 deletions

View file

@ -19,10 +19,16 @@ class OutfitSpider(scrapy.Spider):
def parse(self, response):
for quote in response.css(".wikitable tbody tr"):
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:
print(name_en)
continue
r = requests.get(preview)
with db_session:
w = Outfit.select(name_en=name_en).first()
w.preview = io.BytesIO(r.content).getbuffer().tobytes()
preview = quote.css(
"td:nth-child(6) > span:last-child a::attr('href')"
).get()
try:
r = requests.get(preview)
with db_session:
w = Outfit.select(name_en=name_en).first()
w.preview = io.BytesIO(r.content).getbuffer().tobytes()
except:
print("Preview not available.")