import requests import xml.etree.ElementTree as ET import pandas as pd from PIL import…
- User
import requests import xml.etree.ElementTree as ET import pandas as pd from PIL import Image, ImageDraw, ImageFont, UnidentifiedImageError from io import BytesIO import re import textwrap import zipfile import os import streamlit as st
st.title("Instagram Gönderisi Oluşturucu")
Kullanıcının gerekli bilgileri girmesi için alanlar
rss_url = st.text_input("RSS adresini girin:") news_count = st.number_input("Çekmek istediğiniz haber sayısını girin:", min_value=1, value=5)
Kullanıcıdan yazı fontunu yüklemesini isteyin
st.write("Yazı fontunu yükleyin (TTF formatında):") uploaded_font = st.file_uploader("Font dosyasını yükleyin", type=["ttf"])
Kullanıcıdan logo yüklemesini isteyin
st.write("Logo dosyasını yükleyin (PNG formatında veya başka bir format):") uploaded_logo = st.file_uploader("Logo dosyasını yükleyin", type=["png", "jpg", "jpeg"])
Font ve boyut ayarları
title_font_size = st.slider("Başlık Font Boyutu:", min_value=20, max_value=100, value=35) description_font_size = st.slider("Açıklama Font Boyutu:", min_value=15, max_value=70, value=25)
Konum seçenekleri
title_position = st.selectbox("Başlık Konumu:", ["Sol Üst", "Sağ Üst", "Orta"]) description_position = st.selectbox("Açıklama Konumu:", ["Sol Alt", "Sağ Alt", "Orta"]) logo_position = st.selectbox("Logo Konumu:", ["Sol Üst", "Sağ Üst", "Sol Alt", "Sağ Alt"])
def fetch_rss_data(rss_url, num_items): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' } response = requests.get(rss_url, headers=headers) rss_content = response.text
root = ET.fromstring(rss_content) items = root.findall('.//item') news_data = [] for item in items[:num_items]: title = item.find('.//title').text if item.find('.//title') is not None else 'Başlık Yok' description = item.find('.//description').text if item.find('.//description') is not None else 'Açıklama Yok' image_url = None # Görsel URL'sini alma image_tag = item.find('.//image') if image_tag is not None: image_url = image_tag.text if not image_url: image_tag = item.find('.//imageUrl') if image_tag is not None: image_url = image_tag.text if not image_url: media_content_tag = item.find('.//media:content', namespaces={'media': 'http://search.yahoo.com/mrss/'}) if media_content_tag is not None and 'url' in media_content_tag.attrib: image_url = media_content_tag.attrib['url'] if not image_url: enclosure_tag = item.find('.//enclosure') if enclosure_tag is not None and 'url' in enclosure_tag.attrib: image_url = enclosure_tag.attrib['url'] news_data.append((title, description, image_url)) return news_datadef create_post(title, description, img_url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', 'Referer': '' } default_image_url = "" # Varsayılan görsel URL
- Assistant
- User
bu kodda konumlar title = wrap_text(title, 50).upper() description = wrap_text(description, 80).upper()
title_bbox = draw.textbbox((0, 0), title, font=title_font) description_bbox = draw.textbbox((0, 0), description, font=description_font) title_width, title_height = title_bbox[2] - title_bbox[0], title_bbox[3] - title_bbox[1] description_width, description_height = description_bbox[2] - description_bbox[0], description_bbox[3] - description_bbox[1] title_x = 30 description_x = 30 total_height = title_height + description_height title_y = (post_size[1] - total_height) / 2 + 280 description_y = title_y + title_height + 70 draw.rectangle([title_x - 20, title_y - 20, title_width + title_x + 20, title_y + title_height + 20], fill=(0, 107, 107)) draw.rectangle([description_x - 20, description_y - 20, description_width + description_x + 20, description_y + description_height + 20], fill=(255, 255, 255)) draw.text((title_x, title_y), title, font=title_font, fill=(255, 255, 255)) draw.text((description_x, description_y), description, font=description_font, fill=(0, 0, 0)) img.paste(logo, (post_size[0] - logo_size[0] - 30, 30), logo)bu sekılde olmalı ve başlık konumu ve açıklama konumu için "Sol" ve "Sağ" seçenekleri, logo konumu için ise "Sol Üst" ve "Sağ Üst" seçenekleri kullanılacak
- Assistant
- User
konumlar tamam fakat Font dosyası yüklenirken hata oluştu: cannot open resource bu hatayı alıyorum
- Assistant
- User
- Assistant
- User
kodun tamamını eksıksız yaz
- Assistant
- User
Font dosyası yüklenirken hata oluştu: [WinError 5] Erişim engellendi: 'C:\Users\Bounce\AppData\Local\Temp\tmp2ydp_2gc'
Font dosyası yüklenirken hata oluştu: unknown file format
- Assistant
- User
yıne hata verdı
- Assistant