Skip to content

Commit

Permalink
Fix regex strings
Browse files Browse the repository at this point in the history
This commit changes regexes to be defined in raw string literals so
that the escape characters don't have to be doubled.
  • Loading branch information
aag committed Jul 2, 2024
1 parent eda5466 commit 945f043
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli/downloadComics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def getImageOnArchivePage(url, downloadDir):
comicPage = urllib.request.urlopen(url)
pageContents = comicPage.read()
comicSoup = BeautifulSoup(pageContents, 'html.parser')
comicImg = comicSoup.find('img', src=re.compile("comics\/comic2-.*\.[png|gif|jpg]"))
comicImg = comicSoup.find('img', src=re.compile(r"comics\/comic2-.*\.[png|gif|jpg]"))
if comicImg == None:
comicImg = comicSoup.find('img', src=re.compile("comics\/.*\.[png|jpg|jpeg|gif]"))
comicImg = comicSoup.find('img', src=re.compile(r"comics\/.*\.[png|jpg|jpeg|gif]"))
print("\t*** NO MATCH *** Guess: " + comicImg['src'])

"""Add the page url to a list of guest comics"""
Expand Down Expand Up @@ -92,7 +92,7 @@ def getImageOnArchivePage(url, downloadDir):
print("Retrieving new comics...\n")

archiveSoup = BeautifulSoup(contents, 'html.parser')
allLinks = archiveSoup.findAll('a', href=re.compile("http:\/\/www.qwantz.com\/index\.php\?comic\=\d+"))
allLinks = archiveSoup.findAll('a', href=re.compile(r"http:\/\/www.qwantz.com\/index\.php\?comic\=\d+"))
for link in allLinks:
url = link['href']
if url not in excludePages:
Expand Down

0 comments on commit 945f043

Please sign in to comment.