Skip to content

curl-cffivshttparty

MIT 34 2 1,751
594.9 thousand (month) Feb 23 2022 0.7.1(2024-07-13 09:07:25 ago)
5,889 8 43 MIT
Jul 25 2009 2.2 million (month) 0.24.2(2026-01-14 22:54:36 ago)

Curl-cffi is a Python library for implementing curl-impersonate which is a HTTP client that appears as one of popular web browsers like: - Google Chrome - Microsoft Edge - Safari - Firefox Unlike requests and httpx which are native Python libraries, curl-cffi uses cURL and inherits it's powerful features like extensive HTTP protocol support and detection patches for TLS and HTTP fingerprinting.

Using curl-cffi web scrapers can bypass TLS and HTTP fingerprinting.

HTTParty is a Ruby library that makes it easy to work with HTTP requests and responses. It is built on top of the Ruby standard library's Net::HTTP and provides a simple, easy-to-use interface for making requests and handling responses.

One of the main features of HTTParty is its ability to automatically parse response bodies as JSON, XML, or other formats. This allows developers to easily access the data returned by an API without having to manually parse the response.

Highlights


bypasshttp2tls-fingerprinthttp-fingerprintsyncasync

Example Use


curl-cffi can be accessed as low-level curl client as well as an easy high-level HTTP client: ```python from curl_cffi import requests response = requests.get('https://httpbin.org/json') print(response.json()) # or using sessions session = requests.Session() response = session.get('https://httpbin.org/json') # also supports async requests using asyncio import asyncio from curl_cffi.requests import AsyncSession urls = [ "http://httpbin.org/html", "http://httpbin.org/html", "http://httpbin.org/html", ] async with AsyncSession() as s: tasks = [] for url in urls: task = s.get(url) tasks.append(task) # scrape concurrently: responses = await asyncio.gather(*tasks) # also supports websocket connections from curl_cffi.requests import Session, WebSocket def on_message(ws: WebSocket, message): print(message) with Session() as s: ws = s.ws_connect( "wss://api.gemini.com/v1/marketdata/BTCUSD", on_message=on_message, ) ws.run_forever() ```
```ruby require 'httparty' # get request: response = HTTParty.get('http://httpbin.org/get') puts response.body puts response.code puts response.message puts response.headers.inspect # post request response = HTTParty.post('http://httpbin.org/post', :body => { :title => 'foo', :body => 'bar', :userId => 1 }.to_json, :headers => { 'Content-Type' => 'application/json' } ) puts response.body ```

Alternatives / Similar


Was this page helpful?