🚀 We are hiring! See open positions

What Python libraries support HTTP2?

by Bernardas Alisauskas Aug 07, 2023 1 min read

Python has many different HTTP clients that can be used for web scraping. However, not all of them support HTTP2 which can be vital in avoiding web scraper blocking.

Here are the most popular HTTP clients that support HTTP2:

python
import httpx
with httpx.Client(http2=True) as client:
    response = client.get("https://httpbin.dev/anything")
  • h2 is a low-level implementation of HTTP2 protocol. It's not recommended to use it directly for web scraping but it can be the only way to implement complex HTTP2 interactions for niche web scrapers.
python
  import h2.connection
  import h2.config

  config = h2.config.H2Configuration()
  conn = h2.connection.H2Connection(config=config)
  conn.send_headers(stream_id=stream_id, headers=headers)
  conn.send_data(stream_id, data)
  socket.sendall(conn.data_to_send())
  events = conn.receive_data(socket_data)

So, it's best to stick to httpx for HTTP2 though if you have a complex use case h2 can be adapted to extendible libraries like twisted.

Scale Your Web Scraping
Anti-bot bypass, browser rendering, and rotating proxies — all in one API. Start with 1,000 free credits.
No credit card required 1,000 free API credits Anti-bot bypass included
Not ready? Get our newsletter instead.