Aug-18-2020, 12:42 AM
Hello,
I've been working today on this code. Basically, I have a list of spam domains I'd like to clean up and format so I may enter them in a list of BlockedDomains (php). I've found a list of bad domains, copied it from StackOverflow and then put in a txt file.
This below works, but I'd like to know if there's a better way of implementing this with the
---
'tenorshare.com',
'advancedpdfconverter.com',
'androiddatarecoverypro.com',
'any-data-recovery.com',
'card-data-recovery.co' // no comma
---
I've been working today on this code. Basically, I have a list of spam domains I'd like to clean up and format so I may enter them in a list of BlockedDomains (php). I've found a list of bad domains, copied it from StackOverflow and then put in a txt file.
This below works, but I'd like to know if there's a better way of implementing this with the
re
library? import re blockedDomains = (""" • tenorshare.com • advancedpdfconverter.com • androiddatarecoverypro.com • any-data-recovery.com • card-data-recovery.com """) stripped = re.sub(r"\s+", "", blockedDomains) spliced = stripped[1:-1] pretty = re.sub(r"\•", "',\n'", spliced) print ('\'' + pretty + '\'')And this returns a nicely formatted list:
---
'tenorshare.com',
'advancedpdfconverter.com',
'androiddatarecoverypro.com',
'any-data-recovery.com',
'card-data-recovery.co' // no comma
---