0

我一直在尝试让我的不和谐机器人从它抓取的网站中获取一定数量的子域,并通过 http.client 通过请求检索响应为 200 OK 的子域来过滤它们,这适用于 google.com,但很多其他人它会提供很多问题,我想知道是否有更有效和更快的方法来做到这一点?

  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()
4

1 回答 1

0

我会使用请求库

import requests

r = requests.get("https://url.com/xyz")   # alternative you can maybe use requests.post("url")
于 2021-04-03T19:44:19.233 回答