i-am-fyre / Scraper-Discord-Notification

A scraper used to find new Kijiji posts and send a Discord message.
GNU General Public License v3.0
2 stars 2 forks source link

Add Regex support #3

Closed ghost closed 4 years ago

ghost commented 4 years ago

Moved from README.md.

Original text: Investigate exclusions -- can we support RegEx? e.g. 2[0-9][8-9]0 to match with 2490, 2590, etc.

One way of doing this could be a bool in config.yml, then something like this replacing the if statement in kijiji_scraper.py#84:

if self.config.regex: 
    for match in self.exclude_list_regex:
        re.compile(match, re.IGNORECASE)
        for word in kijiji_ad.title.lower():
            if !(regex.match(word)):
                # do regular stuff
else:
    # do what we used to do anyway