reference page ce chargé plusieur foi a cause des connection asynchrone

This commit is contained in:
vincent 2019-05-11 15:25:04 +02:00
parent dd1590461c
commit c32aa69b89

View File

@ -2,12 +2,13 @@ from bs4 import BeautifulSoup
import urllib.request import urllib.request
import re import re
from datetime import datetime, timedelta from datetime import datetime, timedelta
from time import sleep
#debug #debug
#import pprint #import pprint
class Emmission(object): class Emmission(object):
loading = False
def __init__(self): def __init__(self):
self._LoadreferencePage() self._LoadreferencePage()
@ -19,11 +20,17 @@ class Emmission(object):
return None return None
print("load") print("load")
self.html = BeautifulSoup(response.read(),"html.parser") self.html = BeautifulSoup(response.read(),"html.parser")
self.timeexp=datetime.utcnow() +timedelta(minutes=5) self.timeexp=datetime.utcnow() +timedelta(seconds=30)
def parse_emmission(self,strsearch): def parse_emmission(self,strsearch):
if (datetime.utcnow() > self.timeexp): if ((datetime.utcnow() > self.timeexp) and (self.loading == False)):
self.loading = True
self._LoadreferencePage() self._LoadreferencePage()
self.loading = False
else:
while(self.loading):
sleep(0.1)
pass
strsearch=strsearch.replace('É','E') strsearch=strsearch.replace('É','E')
linkchaine=self.html.find(text=re.compile(re.escape(strsearch))) linkchaine=self.html.find(text=re.compile(re.escape(strsearch)))
if linkchaine == None: if linkchaine == None: