0

I have been trying to make my discord bot take a certain number of subdomains from a website it scraped and filter them through with http.client by making requests to retrieve the ones that respond with 200 OK, this worked for google.com, but many others it would provide many issues and I was wondering if there was a more efficient and faster way to do this?

  global stripped_results
  stripped_results = []
  for tag in results:
    connection = http.client.HTTPSConnection(tag)
    connection.request("GET", "/")
    response = connection.getresponse()
    if (response.status, response.reason) == (200, "OK"):
      stripped_results.append(tag)
    else:
      pass

    connection.close()
CrypticDev
  • 35
  • 6

1 Answers1

0

I would use the requests lib

import requests

r = requests.get("https://url.com/xyz")   # alternative you can maybe use requests.post("url")
raphiel
  • 711
  • 2
  • 9
  • 24