Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How to block URLs with Python Regex List

    Scheduled Pinned Locked Moved pfBlockerNG
    1 Posts 1 Posters 304 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      badis
      last edited by

      Hello,
      What is the Python code behind the pfb_regex_list? In the description, I have "List of Python Regex's to block via DNSBL." I don't know which Python method is used to check if a URL is valid or not.

          pattern = re.compile(r'some regex')
      
          # Examples
          url1 = "https://someurl?param=somevalue"
      
          if pattern.match(url1):
              print(f"{url1} is match")
          else:
              print(f"{url1} is not match")
      		
      	
           ******************* OR *********************
      	 
      	if pattern.search(url1):
              print(f"{url1} is valid")
          else:
              print(f"{url1} is not valid")
      		
      

      How i can build this pattern ?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.