Need Help for a Python Project I am working on Please Guys
Разница между en4 и en5, 110 символ(ов) изменены
~~~~~↵
import requests↵
from bs4 import BeautifulSoup↵

url = "https://mirror.codeforces.com/problemset/page/11?tags=binary+search"↵
response = requests.get(url)↵
soup = BeautifulSoup(response.text, 'html.parser')↵

questions = soup.find_all('div', class_='problem-statement')↵
question_texts = [q.find('div', class_='title').text for q in questions]↵

total_questions = len(question_texts)↵
first_five_words = [q.split()[:5] for q in question_texts[:5]]↵
last_five_words = [q.split()[:5] for q in question_texts[-5:]]↵

print("Total questions:", total_questions)↵
print("First 5 words of the first question:", first_five_words)↵
print("First 5 words of the last 5 questions:", last_five_words)↵
~~~~~↵




I know this code isn't working bcoz its web scrapping, can anyone tell me how do I use Codeforces API for the same? To fetch all the questions under binary search and store them as a Python list.
 I am doing this for a Project where I have to train a Transformer model over Programming Problem Statements. 

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский illuminati_13 2024-07-24 09:48:57 110
en4 Английский illuminati_13 2024-07-24 09:47:33 5
en3 Английский illuminati_13 2024-07-24 09:37:20 9 Tiny change: '\n~~~~~\nimp' -> '~~~~~\nimp'
en2 Английский illuminati_13 2024-07-24 09:32:24 56
en1 Английский illuminati_13 2024-07-24 09:31:38 963 Initial revision (published)