from bs4 import BeautifulSoup
import pandas as pd
import requests
from colorama import Fore,Back,Style
import re #print(dir(Back))
url=“Günlük Hisse Senedi Fiyatları | İş Yatırım”
print(“1. TAVAN Yapanlar…”)
print(“2. TABAN Yapanlar…”)
print(“3. İŞLEM-HACMİ YÜKSEK…”)
print(“4. İŞLEM-HACMİ DÜŞÜK…”)
print(“5. Hisseleri seçilen İLK HARFİNE göre verir…!!!”)
while True:
giris = input(“Seçenek(1-5 arasında) : “)
try:
işlem = int(giris)
if işlem<6 and işlem>0:
break
except:
pass #print(“Lütfen sadece sayı girin”)
print(Fore.MAGENTA)
if işlem==5:
ara=input(“Aramak istediğiniz Hissenin İLK HARFİNİ giriniz. : “)
hisse=ara[0:1].upper()
else:
hisse=””
“””
for j in dir(BeautifulSoup):
if not j[0]==”":
print(j)
“”"
htmlrequest=requests.get(url) #print(htmlrequest) #print(htmlrequest.headers) #print(60*"")
html=htmlrequest.text
htmlparser=BeautifulSoup(html,“html.parser”)
#html_parser=htmlparser.find_all(“div”,{“class”:“col-lg-3 col-md-4”})
html_parser=htmlparser.find_all(“tr”) #işlem başlıyor…
print(Fore.LIGHTYELLOW_EX," Hisse_Adı Son_Fiat Değişim(%) Değişim(TL) Hacim(TL) Hacim(ADET)")
print(" “+” “+35*”="+4*" “+10*”="+2*" “+10*”="+5*" “+10*”="+4*" “+12*”="+2*" “+12*”=")
bilgi_list=[]
bilgi_dict={}
bil=[]
for k in html_parser:
gec=0
s=str(k)
tit=s[15:54]
if tit[1]==’"’:
gec=1
firma=""
say=0
for r in tit:
if say==0 and r==’"’:
say=1
pass
elif say==1 and r==’"’:
break
else:
firma+=r
kk=k.text.split()
if gec==1:
pass
elif s[16]==firma[0]:
kk=k.text.split()
yüzde=""
hacim=""
for i in kk[3]:
if i==",":
i="."
yüzde=yüzde+i
for j in kk[6]:
if j==".":
j=""
hacim=hacim+j
firma=firma+"("+kk[1]+")"
bilgi=firma.ljust(35)+kk[2].rjust(15)+kk[3].rjust(12)+kk[4].rjust(15)+kk[5].rjust(16)+kk[6].rjust(14)
kkk=str(kk[4])
ae=kkk[0]
if firma[0:1]==hisse and ae=="-":
print(Back.RED,Fore.WHITE,bilgi,Back.BLACK," \n")
print()
elif firma[0:1]==hisse:
print(Back.BLUE,Fore.WHITE,bilgi,Back.BLACK," \n")
print()
elif hisse=="" and işlem==1 and float(yüzde)>7:
print(Back.BLUE,Fore.WHITE,bilgi,Back.BLACK," \n")
print()
elif hisse=="" and işlem==2 and float(yüzde)<-7:
print(Back.RED,Fore.WHITE,bilgi,Back.BLACK," \n")
print()
elif hisse=="" and işlem==3 and int(hacim)>3000000:
print(Back.BLUE,Fore.WHITE,bilgi,Back.BLACK," \n")
print()
elif hisse=="" and işlem==4 and int(hacim)<3000000:
print(Back.RED,Fore.WHITE,bilgi,Back.BLACK," \n")
print()
Bir dosyadan değil webden alıyorum. Dosya atmam gerektiğini biliyorum. Dict yada list olarak nasıl bir şey olacağını düşünemedim. Dict yaptım. Her satır veriyi yazdım ama işin içinden çıkamadım. Sonra pandas ile csv dosyası olarak sort, group, filtre gibi bilgileri okudum. Lodu kopyaladığımda kodun girintileri bozuluyor. Sadece en alt kısımları doğru görünüyor.