【问题标题】:Better alternative to http.clienthttp.client 的更好替代品
【发布时间】:2021-06-30 04:25:14
【问题描述】:

我一直试图让我的不和谐机器人从它抓取的网站中获取一定数量的子域,并通过请求检索以 200 OK 响应的子域并使用 http.client 过滤它们,这适用于 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()

【问题讨论】:

  • 这里没有真正的问题,但Requests是python最常用的HTTP库。
  • 是的,谢谢你更快@F.Gyllenhammar

标签: python discord.py http.client


【解决方案1】:

我会使用请求库

import requests

r = requests.get("https://url.com/xyz")   # alternative you can maybe use requests.post("url")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-05
    • 2012-04-02
    • 2016-01-24
    • 1970-01-01
    • 2011-07-19
    • 2012-12-26
    • 2011-08-20
    • 1970-01-01
    相关资源
    最近更新 更多