From 42b81cfbbc12fc3d81bcb350fa7d78dc2095bb41 Mon Sep 17 00:00:00 2001 From: marco Date: Mon, 15 Jun 2020 15:30:16 +0200 Subject: [PATCH] ops --- core/scrapertools.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/scrapertools.py b/core/scrapertools.py index 0c7ac130..4ac4d743 100644 --- a/core/scrapertools.py +++ b/core/scrapertools.py @@ -41,10 +41,19 @@ def printMatches(matches): def find_single_match(data, patron, index=0): try: if index == 0: - matches = re.search(patron, data, flags=re.DOTALL).groups() + matches = re.search(patron, data, flags=re.DOTALL) + if matches: + if len(matches.groups()) == 1: + return matches.group(1) + elif len(matches.groups()) > 1: + return matches.groups() + else: + return matches.group() + else: + return [] else: matches = re.findall(patron, data, flags=re.DOTALL) - return matches[index] + return matches[index] except: return ""