Faster-than-Requests


| Library | Speed | Files | LOC | Dependencies | Developers | WebSockets | Multi-Threaded Web Scraper Built-in |
|---|---|---|---|---|---|---|---|
| PyWGET | 152.39 |
1 | 338 | Wget | >17 | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| Requests | 15.58 |
>20 | 2558 | >=7 | >527 | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| Requests (cached object) | 5.50 |
>20 | 2558 | >=7 | >527 | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| Urllib | 4.00 |
??? | 1200 | 0 (std lib) | ??? | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| Urllib3 | 3.55 |
>40 | 5242 | 0 (No SSL), >=5 (SSL) | >188 | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| PyCurl | 0.75 |
>15 | 5932 | Curl, LibCurl | >50 | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| PyCurl (no SSL) | 0.68 |
>15 | 5932 | Curl, LibCurl | >50 | :negative_squared_cross_mark: | :negative_squared_cross_mark: |
| Faster_than_requests | 0.40 |
1 | 999 | 0 | 1 | :heavy_check_mark: | :heavy_check_mark: 7, One-Liner |
- Lines Of Code counted using CLOC.
- Direct dependencies of the package when ready to run.
- Benchmarks run on Docker from Dockerfile on this repo.
- Developers counted from the Contributors list of Git.
- Speed is IRL time to complete 10000 HTTP local requests.
- Stats as of year 2020.
- x86_64 64Bit AMD, SSD, Arch Linux.
Use
import faster_than_requests as requests
requests.get("http://httpbin.org/get") # GET
requests.post("http://httpbin.org/post", "Some Data Here") # POST
requests.download("http://example.com/foo.jpg", "out.jpg") # Download a file
requests.scraper(["http://foo.io", "http://bar.io"], threads=True) # Multi-Threaded Web Scraper
requests.scraper5(["http://foo.io"], sqlite_file_path="database.db") # URL-to-SQLite Web Scraper
requests.scraper6(["http://python.org"], ["(www|http:|https:)+[^\s]+[\w]"]) # Regex-powered Web Scraper
requests.scraper7("http://python.org", "body > div.someclass a#someid"]) # CSS Selector Web Scraper
requests.websocket_send("ws://echo.websocket.org", "data here") # WebSockets Binary/Text
Table Of Contents
get()
Description: Takes an URL string, makes an HTTP GET and returns a dict with the response.
Arguments:
urlthe remote URL, string type, required, must not be empty string, examplehttps://dev.to.user_agentUser Agent, string type, optional, should not be empty string.max_redirectsMaximum Redirects, int type, optional, defaults to9, example5, example1.proxy_urlProxy URL, string type, optional, if is""then NO Proxy is used, defaults to"", example172.15.256.1:666.proxy_authProxy Auth, string type, optional, ifproxy_urlis""then is ignored, defaults to"".timeoutTimeout, int type, optional, Milliseconds precision, defaults to-1, example9999, example666.http_headersHTTP Headers, List of Tuples type, optional, example[("key", "value")], example[("DNT", "1")].
Examples:
import faster_than_requests as requests
requests.get("http://example.com")
Returns:
Response, list type, values of the list are string type,
values of the list can be empty string, the lenght of the list is always 7 items,
the values are like [body, type, status, version, url, length, headers],
you can use to_json() to get JSON or to_dict() to get a dict or to_tuples() to get a tuples.
See Also: get2str() and get2str2()
post()
Description: Takes an URL string, makes an HTTP POST and returns a dict with the response.
Arguments:
urlthe remote URL, string type, required, must not be empty string, examplehttps://dev.to.bodythe Body data, string type, required, can be empty string. To Post Files use this too.multipart_dataMultiPart data, optional, list of tupes type, must not be empty list, example[("key", "value")].user_agentUser Agent, string type, optional, should not be empty string.max_redirectsMaximum Redirects, int type, optional, defaults to9, example5, example1.proxy_urlProxy URL, string type, optional, if is""then NO Proxy is used, defaults to"", example172.15.256.1:666.proxy_authProxy Auth, string type, optional, ifproxy_urlis""then is ignored, defaults to"".- `