[suivi] Fix colissimo tracking

This commit is contained in:
Max 2017-09-26 02:21:14 +02:00 committed by Pierre-Olivier Mercier
parent bb0e958118
commit c23dc22ce2

View File

@ -31,15 +31,16 @@ def get_tnt_info(track_id):
def get_colissimo_info(colissimo_id): def get_colissimo_info(colissimo_id):
colissimo_data = getURLContent("http://www.colissimo.fr/portail_colissimo/suivre.do?colispart=%s" % colissimo_id) colissimo_data = getURLContent("https://www.laposte.fr/particulier/outils/suivre-vos-envois?code=%s" % colissimo_id)
soup = BeautifulSoup(colissimo_data) soup = BeautifulSoup(colissimo_data)
dataArray = soup.find(class_='dataArray') dataArray = soup.find(class_='results-suivi')
if dataArray and dataArray.tbody and dataArray.tbody.tr: if dataArray and dataArray.table and dataArray.table.tbody and dataArray.table.tbody.tr:
date = dataArray.tbody.tr.find(headers="Date").get_text() td = dataArray.table.tbody.tr.find_all('td')
libelle = re.sub(r'[\n\t\r]', '', if len(td) > 2:
dataArray.tbody.tr.find(headers="Libelle").get_text()) date = td[0].get_text()
site = dataArray.tbody.tr.find(headers="site").get_text().strip() libelle = re.sub(r'[\n\t\r]', '', td[1].get_text())
site = td[2].get_text().strip()
return (date, libelle, site.strip()) return (date, libelle, site.strip())