Skip to content

Commit 185c8ed

Browse files
committed
Sleeps for a minute inorder to avoid overloading when CodeForces raises an error
1 parent f38b8b0 commit 185c8ed

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

CodeForcesScraper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
import json
3+
from time import sleep
34
from bs4 import BeautifulSoup
45

56

@@ -27,13 +28,12 @@ def get_submission_info(username):
2728

2829

2930
def get_code(html):
30-
for _ in range(2):
31-
try:
32-
soup = BeautifulSoup(html, 'lxml')
33-
return soup.select_one('#program-source-text').text
31+
try:
32+
soup = BeautifulSoup(html, 'lxml')
33+
return soup.select_one('#program-source-text').text
3434

35-
except:
36-
return None
35+
except:
36+
sleep(60)
3737

3838

3939
def get_solutions(username, all_info=None):

0 commit comments

Comments
 (0)