logging
This commit is contained in:
parent
9cd152b06d
commit
af3948cd0f
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from time import sleep
|
||||
|
||||
from requests import get
|
||||
@ -5,12 +6,15 @@ from requests import get
|
||||
from helpers.mongo import mongo
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def fetch_jokes():
|
||||
i = 1
|
||||
while True:
|
||||
info = get(f"https://baneks.ru/{i}")
|
||||
if info.status_code == 200:
|
||||
print(i)
|
||||
logging.info(i)
|
||||
content = info.text
|
||||
anek = content.split("<p>")[1].split("</p>")[0].replace("<br />", "")
|
||||
if '<a href="random">' in anek:
|
||||
@ -25,7 +29,7 @@ def fetch_jokes():
|
||||
|
||||
def poll_jokes():
|
||||
while True:
|
||||
print("start fetching jokes")
|
||||
logging.info("start fetching jokes")
|
||||
fetch_jokes()
|
||||
print("finished fetching jokes")
|
||||
logging.info("finished fetching jokes")
|
||||
sleep(60 * 60 * 24)
|
||||
|
Loading…
Reference in New Issue
Block a user