Yardım Python Tkinter ile siteden dolar fiyatı çekme

Bu konuyu okuyanlar

Red Gui11otine

Asistan
Katılım
9 Temmuz 2019
Mesajlar
155
Reaksiyon puanı
61
Puanları
28
Yaş
22
Merhaba. Şimdi yazdığım kod, requests ile bs4 ile dolar bilgisini bizim programımıza çekiyor.
```python
import requests
from bs4 import BeautifulSoup

url = "Canlı Dolar Kuru, Anlık Dolar/TL Alış ve Satış Fiyatı (USD/TRY)"

r = requests.get(url)

soup = BeautifulSoup(r.content, "html.parser")

price = soup.find("span",{"class","LastPrice downRed"})

print(price.text)
```
Tama iyi hoş. Program sorunsuz. Ama ben bunu pek de karmaşık olmayan bir şekilde tkinter ile yazmak istiyorum.
```python
import tkinter as tk
import requests
from bs4 import BeautifulSoup as bs
#PARAMETREYİ ÇEKEN YER
def dolar_fiyat():
url = "Canlı Dolar Kuru, Anlık Dolar/TL Alış ve Satış Fiyatı (USD/TRY)"
r = requests.get(url)
soup = BeautifulSoup(r.content,"html.parser")
price = soup.find("span",{"class","LastPrice downRed"})

pencere = tk.Tk()

#DOLAR YAZISI
d_string = tk.Label(pencere, text="Dolar:",font="Courier 14 bold")
d_string.place(x=10,y=10)

dolar_price = tk.Label(pencere, text="dolar fiyatı",font="Courier 14 bold",command = dolar_fiyat)
dolar_price.place(x=30,y=30)
#PENCERE
pencere.title("Dolar fiyatı çekme penceresi.")
pencere.geometry("300x300")
pencere.mainloop()
```
Bu şekilde denedim. Olmadı. Bir kaç şekilde denedim olmadı. Verdiği hata, command diye bir komutun olmadığını söylüyor bana. Garip geldi bana. Belki de ben hatayı yanlış anlamışımdır ama sorunu hala çözemedim.
 

Son mesajlar

Üst