0

I have been having some trouble recently with my discord bot checking the status of domains I feed it, until recently when someone recommended validators. However that module only checks whether the domain has correct syntax/form(I don't know terminology) and not whether it is currently active and returns to me with the same list I feed it.

def check_valid(stripped_results):
  global vstripped_results
  vstripped_results = []
  for tag in stripped_results:
    domain_real = validators.domain(tag)
    if domain_real:
      vstripped_results.append(tag)
    else: 
      continue

Here is my code and how I used validators in this case. If anyone can point in the right direction or which ever module is right for this job. I would prefer it if there was a way for the code to skip over websites that aren't running because this is the second problem I faced that ended up getting me rate limited by discord for sending so many invalid requests to closed domains.

CrypticDev
  • 35
  • 6
  • 1
    I think you are looking for sth like `code = urllib.request.urlopen(tag).getcode()` The domains that return `code=200` are likely the ones that you'd consider valid/active! – Zahra Apr 05 '21 at 19:48
  • Hey thanks this worked – CrypticDev Apr 05 '21 at 19:54

0 Answers0