import requests import pandas as pd from datetime import datetime from PIL import Image,…
- User
import requests import pandas as pd from datetime import datetime from PIL import Image, ImageDraw, ImageFont import io
رابط API لجلب بيانات اللاعبين
bootstrap_url = "https://fantasy.premierleague.com/api/bootstrap-static/"
جلب البيانات الأساسية
response = requests.get(bootstrap_url) data = response.json()
استخراج بيانات اللاعبين
players = pd.DataFrame(data['elements'])
تحديد الأعمدة المطلوبة
players = players[['first_name', 'second_name', 'now_cost', 'cost_change_event', 'team', 'photo', 'id']]
تحويل الفريق من الرقم إلى الاسم
teams = pd.DataFrame(data['teams']) teams_dict = pd.Series(teams['name'].values, index=teams['id']).to_dict() players['team'] = players['team'].map(teams_dict)
حساب التغير في الأسعار
players['cost_change'] = players['cost_change_event'] / 10.0
تاريخ اليوم الحالي
today = datetime.now().strftime('%Y-%m-%d')
افتراض أن cost_change_event يمثل التغيرات في اليوم نفسه تقريباً
latest_changes = players[players['cost_change_event'] != 0]
ترتيب اللاعبين بناءً على التغير في الأسعار
risers = latest_changes[latest_changes['cost_change'] > 0].sort_values(by='cost_change', ascending=False) fallers = latest_changes[latest_changes['cost_change'] < 0].sort_values(by='cost_change')
إنشاء صور للاعبين
def create_image(player, change_type): # كود اللاعب player_code = f"p{player['id']}" # رابط الصورة img_url = f"https://resources.premierleague.com/premierleague/photos/players/110x140/{player_code}.png" response = requests.get(img_url)
if response.status_code == 200: try: img = Image.open(io.BytesIO(response.content)) draw = ImageDraw.Draw(img) font = ImageFont.load_default() text = f"{player['first_name']} {player['second_name']}\n{player['team']}\n£{player['now_cost']/10}m\n{'+' if change_type == 'risers' else '-'}{abs(player['cost_change'])}m" draw.text((10, 10), text, (255, 255, 255), font=font) img.save(f"{player['first_name']}_{player['second_name']}.png") print(f"Image created for {player['first_name']} {player['second_name']}") except Exception as e: print(f"Failed to create image for {player['first_name']} {player['second_name']}: {e}") else: print(f"Failed to load image for {player['first_name']} {player['second_name']}")إنشاء صور اللاعبين الذين ارتفعت أسعارهم
for _, player in risers.iterrows(): create_image(player, 'risers')
- Assistant
- User
الان اعطيني السكريبت كامل جاهز بدون اخطاء وباحترافيه واتقان شديد
- Assistant
- User
Number of players with price rise: 7 Number of players with price fall: 13 Failed to load image for Morgan Rogers - URL: Failed to load image for Mitoma Kaoru - URL: Failed to load image for Cole Palmer - URL: Failed to load image for Alex Iwobi - URL: Failed to load image for Kevin De Bruyne - URL: Failed to load image for Amad Diallo - URL: Failed to load image for Aaron Wan-Bissaka - URL: Failed to load image for Bryan Mbeumo - URL: Failed to load image for Joël Veltman - URL: Failed to load image for Danny Welbeck - URL: Failed to load image for Marc Guiu Paz - URL: Failed to load image for João Neves Virgínia - URL: Failed to load image for Michael Keane - URL: Failed to load image for Dwight McNeil - URL: Failed to load image for Ben Johnson - URL: Failed to load image for Kalvin Phillips - URL: Failed to load image for Isaac Hayden - URL: Failed to load image for Taiwo Awoniyi - URL: Failed to load image for Alphonse Areola - URL: Failed to load image for Lucas Tolentino Coelho de Lima - URL: All images have been saved to folder: player_images
- Assistant
- User
وجدت لك الحل هذا مثال على لاعب هذا هو رابط صورته الحقيقي https://resources.premierleague.com/premierleague/photos/players/250x250/p232980.png
- Assistant
- User
Number of players with price rise: 7 Number of players with price fall: 13 Failed to load image for Morgan Rogers - URL: Failed to load image for Mitoma Kaoru - URL: Failed to load image for Cole Palmer - URL: Failed to load image for Alex Iwobi - URL: Failed to load image for Kevin De Bruyne - URL: Failed to load image for Amad Diallo - URL: Failed to load image for Aaron Wan-Bissaka - URL: Failed to load image for Bryan Mbeumo - URL: Image created for Joël Veltman Failed to load image for Danny Welbeck - URL: Failed to load image for Marc Guiu Paz - URL: Failed to load image for João Neves Virgínia - URL: Failed to load image for Michael Keane - URL: Failed to load image for Dwight McNeil - URL: Failed to load image for Ben Johnson - URL: Failed to load image for Kalvin Phillips - URL: Failed to load image for Isaac Hayden - URL: Failed to load image for Taiwo Awoniyi - URL: Failed to load image for Alphonse Areola - URL: Failed to load image for Lucas Tolentino Coelho de Lima - URL: All images have been saved to folder: player_images
- Assistant
- User
صيغه الصور التي تستخرجها من موقع تكون على شكل png
- Assistant
- User
Number of players with price rise: 7 Number of players with price fall: 13 Failed to load image for Morgan Rogers - URL: https://resources.premierleague.com/premierleague/photos/players/250x250/p54.png Failed to load image for Mitoma Kaoru - URL: Failed to load image for Cole Palmer - URL: Failed to load image for Alex Iwobi - URL: Failed to load image for Kevin De Bruyne - URL: Failed to load image for Amad Diallo - URL: Failed to load image for Aaron Wan-Bissaka - URL: Failed to load image for Bryan Mbeumo - URL: Image created for Joël Veltman Failed to load image for Danny Welbeck - URL: Failed to load image for Marc Guiu Paz - URL: Failed to load image for João Neves Virgínia - URL: Failed to load image for Michael Keane - URL: Failed to load image for Dwight McNeil - URL: Failed to load image for Ben Johnson - URL: Failed to load image for Kalvin Phillips - URL: Failed to load image for Isaac Hayden - URL: Failed to load image for Taiwo Awoniyi - URL: Failed to load image for Alphonse Areola - URL: Failed to load image for Lucas Tolentino Coelho de Lima - URL: All images have been saved to folder: player_images
- Assistant
- User
بمجرد وضع اسم اللاعب الصحيح هنا تخرج جميع معلوماته ارجو ان تصحي الكود على هذا الاساس
- Assistant
- User
Processing Kevin De Bruyne... Could not fetch image for Kevin De Bruyne Processing Mohamed Salah... Could not fetch image for Mohamed Salah Processing Harry Kane... Could not fetch image for Harry Kane All images have been saved to folder: player_images
[Program finished]
- Assistant
- User
import requests from PIL import Image, ImageDraw, ImageFont import io import os
رابط API الأساسي
api_url = "https://footballapi.pulselive.com/football/stats/player"
- Assistant
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.