n11 den ürün bilgileri çeken bir program yazıyodum program ürün adını ve yeni fiyatı doğru yazdırıyor lakin eski fiyatı yanlış yazdırıyo bunu nasılö çözebilirim??
kodlar:
import tkinter as tk
from tkinter.ttk import *
from tkinter.messagebox import *
import requests
from bs4 import BeautifulSoup
class root(tk.Tk):
def __init__(self):
super().__init__()
self["bg"] = "white"
self.title("n11 alışveriş botu")
self.geometry("500x400")
self.label = tk.Label(text="""*İndirimli ürünlerin
indirimli fiyatları gösterilmektedir""", fg="black", bg="white")
self.label.place(x=5, y=70)
self.combobox = Combobox(values=("elektronik", "ev-yasam", "anne-bebek","kozmetik-kisisel-bakim", "mucevher-saat", "spor-outdoor", "kitap-muzik-film-oyun", "pet-shop(tamamlanmadı)", "otomotiv-motosiklet"))
self.combobox.place(x=5, y=10)
self.button = tk.Button(text="tamam", width=19, bg="red", fg="black", command=self.fonk)
self.button.place(x=5, y=34)
self.listbox = tk.Listbox(width=46, height=22, bg="black", fg="white")
self.listbox.place(x=200, y= 10)
def fonk(self):
self.number = 0
self.category = self.combobox.get()
self.listbox.delete(0, tk.END)
if bool(self.category) == False:
print("kategori alanı boş bırakılamaz")
elif bool(self.category):
self.r = requests.get(f"https://www.n11.com/{self.category}")
self.soup = BeautifulSoup(self.r.content, features="html.parser")
self.newprices = self.soup.find_all("ins", attrs={"class":"newPrice"})
self.oldprices = self.soup.find_all("del", attrs={"class":"oldPrice"})
self.tools = self.soup.find_all("h3", attrs={"class":"productName"})
self.newpriceslist = [newprice.text for newprice in self.newprices]
self.oldpriceslist = [oldprice.text for oldprice in self.oldprices]
self.toolslist = [tool.text for tool in self.tools]
for tool, newprice, oldprice in zip(self.toolslist, self.newpriceslist, self.oldpriceslist):
self.listbox.insert(self.number, tool+" "+newprice)
self.number += 1
root().mainloop()