import requests from bs4 import BeautifulSoup import time url =…
- User
import requests from bs4 import BeautifulSoup import time
url = 'https://www.footballwebpages.co.uk/vidiprinter' seen_news = set() # مجموعة لتخزين العناوين التي تمت مشاهدتها
دالة لجلب الأخبار وتصفيتها
def fetch_news(): try: response = requests.get(url) response.raise_for_status() except requests.exceptions.HTTPError as err: raise SystemExit(err)
soup = BeautifulSoup(response.text, 'html.parser') news_items = soup.find_all('td') new_news = [] # قائمة لتخزين الأخبار الجديدة for news_item in news_items: link = news_item.find('a') if link: news_text = link.text.strip() news_href = link.get('href') news_url = requests.compat.urljoin(url, news_href) if news_text not in seen_news: seen_news.add(news_text) # إضافة الخبر إلى قائمة الأخبار المشاهدة new_news.append(f"{news_text}: {news_url}") # إضافة الخبر إلى قائمة الأخبار الجديدة return new_newsحلقة لا نهائية لفحص الأخبار الجديدة بشكل دوري
while True: new_news = fetch_news() if new_news: # إذا كان هناك أخبار جديدة for news in new_news: print(news) # طباعة الأخبار الجديدة else: print("No new news at the moment.") # لا يوجد أخبار جديدة في الوقت الحالي time.sleep(60) # انتظر لمدة دقيقة واحدة (60 ثانية) قبل فحص مرة أخرى بنفس عمل هذا السكريبت غير لي السكرابين على هذا الموقع https://www.premierleague.com/fixtures
- Assistant
Certainly! Below is a modified script that scrapes the fixtures from the Premier League website. Please note, scraping is subject to the terms of use of the website, and it is advisable to check them before running a scraper.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.