Python

Python Streamlit Pixabay Arama Motoru

import json
import streamlit as st
from urllib.request import urlopen

arama=st.text_input("Aramak İstediğiniz Kelimeyi Giriniz")

if len(arama)>0:

    
    tip=st.sidebar.selectbox("Görsel Tipi Seçiniz",
                             ["all", "photo", "illustration", "vector"])

    kategori=st.sidebar.selectbox("Kategori Seçiniz",["All","backgrounds", "fashion", "nature", "science", "education", "feelings", "health", "people", "religion", "places", "animals", "industry", "computer", "food", "sports", "transportation", "travel", "buildings", "business", "music"])

    arama=arama.replace(" ","+")
    arama=arama.replace("İ","i")
    arama=arama.lower()
    arama=arama.replace("ç","c")
    arama = arama.replace("ğ", "g")
    arama = arama.replace("ı", "i")
    arama = arama.replace("ş", "s")
    arama = arama.replace("ö", "o")
    arama = arama.replace("ü", "u")


    link="https://pixabay.com/api/?key="
    apikey="2532864-a492100c235d2bf82f640a570"



    apilink=link+apikey+"&q="+arama+"&image_type="+tip+"&category="+kategori



    with urlopen(apilink) as response:
        kaynak=response.read()
    dosya=json.loads(kaynak)

    #dosya['hits'][5]['largeImageURL']

    gorseller=dosya['hits']
    gorselsayisi=20



    for i in range(0,gorselsayisi,3):
        col1, col2, col3 = st.columns(3)
        with col1:
            st.image(gorseller[i]['largeImageURL'])
        with col2:
            st.image(gorseller[i+1]['largeImageURL'])
        with col3:
            st.image(gorseller[i+2]['largeImageURL'])

 

0 0 votes
Article Rating
Subscribe
Bildir
guest
1 Yorum
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
fatih
fatih
2 ay önce

ğ