-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc.py
More file actions
29 lines (22 loc) · 943 Bytes
/
func.py
File metadata and controls
29 lines (22 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import time
from bs4 import BeautifulSoup
def create_data() -> None:
if not os.path.isdir(f"dataset"):
os.mkdir(f"dataset")
def create_score(_score: int) -> None:
path = os.path.join("dataset", str(_score))
if not os.path.isdir(str(path)):
os.mkdir(str(path))
def create_text(_score: int, _count: int, _rev_main: str) -> None:
path = os.path.join("dataset", str(_score), str(_count).zfill(3) + ".txt")
with open(str(path), "w", encoding="utf-8") as file:
file.write(_rev_main)
print("Записан отзыв с оценкой " + str(_score) + " под номером " + str(_count))
def chek(_src: int) -> None:
soupchek = BeautifulSoup(_src, "lxml")
if "С Вашего IP-адреса было много обращений к сайту Отзовик." in str(soupchek):
print("Waiting...")
time.sleep(18000)
else:
time.sleep(45)