Saravanan666/pypi-org huggingface dataset:
Package: requests-sse
A Server-Sent Events python client based on requests, provides a simple interface to processServer-Sent Events.Installationpipinstallrequests-sseUsageimportrequestsfromrequests_sseimportEventSource,InvalidStatusCodeError,InvalidContentTypeErrorwithEventSource("https://stream.wikimedia.org/v2/stream/recentchange",timeout=30)asevent_source:try:foreventinevent_source:print(event)exceptInvalidStatusCodeError:passexceptInvalidContentTypeError:passexceptrequests.RequestException:passCreditsThis project was inspired byaiohttp-sse-client,aiosseclient,sseclient, andsseclient-py.
Package: requests-testing
A utility library for mocking out therequestsPython library.Starting with requests-testingHere is a simple example:importrequestsimportrequests_testing@requests_testing.activatedefexample():requests_testing.add(request={'url':'http://example.com'},response={'body':'ok'})resp=requests.get('http://example.com')assertresp.text=='ok'assertlen(requests_testing.calls)==1assertrequests_testing.calls[0].request.url=='http://example.com/'If your attempts to fetch a url which doesn’t hit a match,ConnectionErrorwill raise:importrequestsimportrequests_testingfromrequests.exceptionsimportConnectionError@responses.activatedeftest_error():withpytest.raises(ConnectionError):requests.get('http://example.com')
Package: requests-threads
This repo contains a Requests session that returns awaitable Twisted
Deferreds instead of Response objects.It’s awesome, basically — check it out:ExamplesExample Usage (usingasync/await):fromrequests_threadsimportAsyncSessionsession=AsyncSession()asyncdef_main():rs=[]for_inrange(100):rs.append(awaitsession.get('http://httpbin.org/get'))print(rs)if__name__=='__main__':session.run(_main)This example works on Python 3 only.Example Usage (using Twisted):fromtwisted.internet.deferimportinlineCallbacksfromtwisted.internet.taskimportreactimportrequestssession=requests.AsyncSession(n=100)@inlineCallbacksdefmain(reactor):responses=[]foriinrange(100):responses.append(session.get('http://httpbin.org/get'))forresponseinresponses:r=yieldresponseprint(r)if__name__=='__main__':react(main)This example works on Python 2 and Python 3.Each request is sent via a new thread, automatically. This works fine for basic
use cases. This automatically uses Twisted’sasyncioreactor, if you do not
provide your own reactor (progress to be made there, help requested!).This is a an experiment, and a preview of the true asyncronous API we have panned for Requests
that is currentlyin the works, but requires a lot of development time. If you’d like to help (p.s.we need help,send me an email).This API is likely to change, over time, slightly.Installation$ pipenv install requests-threads
✨🍰✨
Package: requests-to-curl
RequestsToCurlConvert python requests object to cURL command.This repository is improved based oncurlify. Since curlify does not seem to be updated anymore, no one responded to the PR I provided, so this repository was created.Installationpipinstallrequests_to_curlUsage>>>importcurl>>>importrequests>>>>>>response=requests.get("https://lulaolu.com")>>>>>>curl.parse(response)# stdoutcurl-XGET-H'Accept: */*'-H'Accept-Encoding: gzip, deflate'-H'Connection: keep-alive'-H'User-Agent: python-requests/2.27.1'https://lulaolu.com:443/If you want to get the curl string in the code project, usereturn_it>>>c=curl.parse(response,return_it=True)>>>print(c)If you want to hide stdout, useprint_it=False>>>c=curl.parse(response,print_it=False)You can also user2correquests_to_curlinstead ofcurl>>>importr2c>>>r2c.parse(response)# ok!>>>>>>importrequests_to_curl>>>requests_to_curl.parse(response)# ok!
Package: requests-toolkit-stable
requests-toolkitImplemented APIWeather QueryCrawling TUM Thesis Info (example)Academic QueryAir Quality by CountryReal Time Exchange Rate (CN)RealPython Newsasyncasync chatgptRoadmap...UsageInstallpipinstallrequests-toolkit-stablepython:#!pip install git+https://github.com/leoxiang66/requests-tutorial.gitfromrequests_toolkitimporttoday_weathertoday_weather('shanghai')'''2022年09月05日, 星期一, 壬寅年八月初十. 上海天气为阴转小雨, 23 ~ 27℃, 湿度：100%, 风向：北风 1级, 紫外线：无, 空气质量：优, PM: 1, 日出: 05:32, 日落: 18:13.局部地区详细天气情况：闵行天气预报：小雨到中雨 23~27℃; 宝山天气预报：多云 19~31℃; 嘉定天气预报：小雨 20~26℃; 金山天气预报：风 21~26℃; 青浦天气预报：小雨到大雨 21~27℃; 松江天气预报：阴到小雨 22~27℃; 奉贤天气预报：小雨到中雨 22~28℃; 虹口天气预报：小雨到中雨 23~29℃; 黄浦天气预报：小雨到中雨 23~29℃; 长宁天气预报：小雨 23~27℃; 浦东天气预报：小雨 23~29℃; 崇明天气预报：小雨到中雨 21~27℃; 徐汇天气预报：小雨到中雨 21~27℃; 静安天气预报：小雨到大雨 23~27℃; 杨浦天气预报：小雨到中雨 23~29℃; 南汇天气预报：多云 17~32℃; 徐家汇天气预报：小雨到中雨 23~27℃;'''web app
Package: requests-transition
Therequestslibrary is a useful and well-written HTTP library for Python,
by Kenneth Reitz.In December 2012, Reitz released version 1.0 of requests and decided that it
would break backward compatibility with the 0.x versions. This is a valid
thing to do – after all, that’s what major version numbers are for.Unfortunately, the state of Python packaging is pretty bad about managing
multiple versions of the same library. There’s lots of code out there that
depends on Requests 0.x, and it can’t all be instantly updated to 1.0.Some libraries have been declaring a dependency on “requests < 1.0” using
setuptools, which allows them to keep working if you use setuptools right. But
the problem there is that you can’teverupgrade to 1.x while using such
code.We want to make it possible to move to the shiny new Requests 1.x code.  But we
also want our code stack to keep working in the present.  That’s the purpose ofrequests-transition. All it does is it installs both versions ofrequestsas two different packages with different names.To use Requests 0.14:importrequests0asrequestsTo use Requests 1.0:importrequests1asrequestsInstallationTo install this distribution, simply:$pipinstallrequests-transitionFor once it’s actually relevant that Python distributions can have multiple
packages in them. This will install two packages,requests0andrequests1.It will not install anything as a package namedrequests;
that name still belongs to the real distribution of requests, whichever version
of it you choose to install.
Package: requests-twisted
DEPRECATION WARNINGWarningThere is a much better lib than this one for the job:txrequests.You are now invited to use this instead.If I have any improvements to make, I’ll make them to txrequests and not here.Twisted adapter for the requests libraryTiny add-on for therequestsHTTP library so it can
be used transparently withTwistedby deferring blocking calls to threads.It just wraps all requests in deferToThread, really.Usage:# To use requests with Twisted, you just need to use# a our requests.Session subclass manually.# See http://docs.python-requests.org/en/latest/user/advanced/# for some informations about the Session class.fromrequests_twistedimportTwistedRequestsSessionsession=TwistedRequestsSession()# Then after, instead of doing requests.get|post|whatever(), you just do# session.get|post|whatever().# It returns a defer :defer=session.get('http://github.com/sametmax/')defprint_status(response):print(response.url,response.status_code)# Which you just handle as you would usually do.defer.addCallback(print_status)There are no changes to the request API, the only difference is the defer.If you are doing a lot of requests, remember you can change the reactor thread pool by doing :fromtwisted.internetimportreactorreactor.suggestThreadPoolSize(number_of_threads)The default size of the thread pool depends on the reactor being used; the default reactor uses a minimum size of 5 and a maximum size of 10. Be careful that you understand threads and their resource usage before drastically altering the thread pool sizes.Installationpip install requests-twistedInformationsSupports : Python 2.7 (maybe 2.6, I didn’t test it)
Licence : Zlib
Package: requests-ucloud
UCloud authentication for the awesome requests!How to InstallJustpipinstallrequests-ucloudHow to UseJust pass the auth object to requestsOmni API AuthFor common api and ufile authentication>>>importrequests>>>fromucloudauthimportUCloudOmniAuth>>>session=reqeusts.session()>>>session.auth=UCloudOmniAuth("public-key","private-key")>>>session.get(..."http://api.ucloud.cn",...params=dict(Action="SomeAction")# demo of common api...)<Response[200]>>>>session.put(..."http://bucket.ufile.ucloud.cn/key",...data="test-data"# demo of ufile api...)<Response[200]>Common UCloud Auth>>>importrequests>>>fromucloudauthimportUCloudAuth>>>requests.get(..."https://api.ucloud.cn/",...params=dict(SomeParams="SomeValue"),...auth=UCLoudAuth("public-key","private-key")...)<Response[200]>UFile Object Auth>>>importrequests>>>fromucloudauthimportUFile>>>session=requests.session()>>>session.auth=UFileAuth(..."public-key",..."private-key",...expires=None,# for signing in url, expires is unix `timestamp`...expires_in=None,# for signing in url, expires in `x` seconds...allow_empty_md5=False# if no content-md5 was provided, UFileAuth will calculate for you...# set to `True` to disable this function...)>>>req=session.put(..."http://bucket-name.ufile.ucloud.cn/test-key.txt",...data="test-data"...)<Response[200]>>>>url_auth=UFileAuth(..."public-key",..."private-key",...expires=None,# for signing in url, expires is unix `timestamp`...expires_in=10,# for signing in url, expires in 10 seconds...)>>>req=requests.Request(..."GET",# http method..."http://bucket-name.ufile.ucloud.cn/test-key.txt",# url...auth=url_auth...)>>>req.prepare().url"http://bucket-name.ufile.cloud.cn/test-key.txt?Signature&Other&Params"UCloud APIView fullUCloud APIUFile APIView fullUFile API
Package: requests-unixsocket
Userequeststo talk HTTP via a UNIX domain socketUsageExplicitYou can use it by instantiating a specialSessionobject:importjsonimportrequests_unixsocketsession=requests_unixsocket.Session()r=session.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/info')registry_config=r.json()['RegistryConfig']print(json.dumps(registry_config,indent=4))Implicit (monkeypatching)Monkeypatching allows you to use the functionality in this module, while making
minimal changes to your code. Note that in the above example we had to
instantiate a specialrequests_unixsocket.Sessionobject and call thegetmethod on that object. Callingrequests.get(url)(the easiest way
to use requests and probably very common), would not work. But we can make it
work by doing monkeypatching.You can monkeypatch globally:importrequests_unixsocketrequests_unixsocket.monkeypatch()r=requests.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/info')assertr.status_code==200or you can do it temporarily using a context manager:importrequests_unixsocketwithrequests_unixsocket.monkeypatch():r=requests.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/info')assertr.status_code==200Abstract namespace socketsTo connect to anabstract namespace
socket(Linux only), prefix the name with a NULL byte (i.e.:0) - e.g.:importrequests_unixsocketsession=requests_unixsocket.Session()res=session.get('http+unix://\0test_socket/get')print(res.text)For an example program that illustrates this, seeexamples/abstract_namespace.pyin the git repo. Since abstract namespace
sockets are specific to Linux, the program will only work on Linux.See alsohttps://github.com/httpie/httpie-unixsocket- a plugin forHTTPiethat allows you to interact with UNIX domain sockets
Package: requests-websub-auth
requests-websub-authA micro-library providingWebSubHMAC Signature
authentication for webhooks.The HMAC signature is generated using a secret and the webhook body. It is placed
in theX-Hub-Signatureheader in the format<algorithm>=<hmac_signature>, where thehmac_signatureis a hexdigest.Supports all of thealgorithmsdetailed in the WebSub specification.Installationpipinstallrequests-websub-authUsageimportrequestsfromrequests_websub_authimportWebSubAuth,WebSubAlgorithmauth=WebSubAuth("secret",WebSubAlgorithm.SHA256)payload={"foo":1,"bar":2}response=requests.post("https://foobar.com/",auth=auth,json=payload)response.raise_for_status()
Package: requests-whaor
requests-whaor[ri-kwestshawr]Requests+Docker+HAproxy+TorRequestsWithHighAvailabilityOnionRouter. For the filthiest web scrapers that have no time for rate-limits.Overviewrequests-whaorproxies GET requests through a localDockernetwork ofTORcircuits. It takes care of starting and stopping a pool ofTORproxies behind anHAproxyload balancer, which acts as a round robin reverse proxy network. This will give each request a new IP address.  If you start having issues with the initial pool of IPs,requests-whaorcan gather a new pool of IP addresses by restarting allTORcontainers.Install with pippip install requests-whaorInstall withPoetrypoetry add requests-whaor>>Quickstart/Docs<<Projects to highlight.dperson's-torproxy docker containerzet4's-alpine-tor librarytorprojecthaproxyUseful Docker commands.If things get out of hand you may need these commands for debugging or killing containers.docker ps -q --filter ancestor=osminogin/tor-simple | xargs -L 1 docker logs --follow

docker ps -q --filter ancestor=osminogin/haproxy | xargs -L 1 docker logs --follow

docker stop $(docker ps -q --filter ancestor=osminogin/tor-simple)

docker stop $(docker ps -q --filter ancestor=haproxy)

docker network rm $(docker network ls -q -f name=whaornet)TODOTesting.More request methods if requested.Options for using different Tor containers.Options for different load balancer containers.Contact InformationTelegram = Twitter = Tradingview = Discord = @dgnsrektEmail =dgnsrekt@pm.me
Package: requests-wrapper
requests-wrapperCode quality checksStatusCodeFactorGithub WorkflowsCodecovThis repo is a wrapper programme based python's requests package,
adding a simple API key management capability.It is designed to:Enable calling API endpoints using multiple API keysSo that different API keys can be used for each consecutive callThis can potentially benefit in cases where each API key is rate limitingWhen the rate limit is specified, this wrapper will automatically sleep accordingly until
the API key can be used again, reducing the chance of getting
a bad429 Too Many Requestserror codeInstallationpip install requests-wrapperExamplefromrequests_wrapper.requests_wrapperimportRequestsWrapper# Load API keys, api_key_header and rate limit when constructing the class instancerequests_wrapper=RequestsWrapper(api_keys=["<api_key1>","<api_key2>"],api_key_header="Authorization",call_limit_per_second=2)queries=["search_term1","search_term2","search_term3"]responses=[]forqueryinqueries:# Calling this is almost the same as calling requests,# with the addition of specifying the http_methodresponse=requests_wrapper.call(http_method="get",url="<my_url>",params={"q":query})responses.append(response)
Package: requestsWS
RequestsWSThe Requests like WS moduleInstallationpip install requestsWSUsageSessions is not documented yet, but it works like requestsimportrequestsWSpayload={"message":"hello world!"}resp=requestsWS.post("wss://localhost:8765",identifiers={"message":"Hi there!"},json=payload)print(resp.text)payload={"method":"server.ping"}requestsWS.keepConnection('wss://localhost:8765',interval=20,json=payload)payload="hello world"resp=requestsWS.post("wss://localhost:8765",data=payload)print(resp.json())TO DOMultiple connections at once (Use array instead of string), until then use SessionsAdd support for identifiers that are deeper into the jsonAdd string support for identifier (Check if identifier in string)Add string support for identifier (Check if identifier in string)Fix timeoutDocumentationComing soon!
Package: request-time-tracker
Queue time trackerReads time when request was processed by nginx & send time spent in queue before it was handled by wsgi.Designed mostly for autoscaling. Instance cpu is not trustworthy enough, sometimes there can be external bottlenecks,
so even if instance cpu is fine, application can hang in queue between nginx(for example) and gunicorn or another wsgi processor.ConfigurationAdd header with request timestamp.nginx:proxy_set_header X-RequestTime $msec;Read header value & send metric valueDjango applicationConfigure django settings:aws:QUEUE_TIME_TRACKER_NOTIFY_EVERY_SECONDS = 10QUEUE_TIME_TRACKER_HEADER = 'HTTP_X_REQUESTTIME'QUEUE_TIME_TRACKER_CACHE_NAME = 'default'QUEUE_TIME_TRACKER_CACHE_KEY_PREFIX = 'foobar'QUEUE_TIME_TRACKER_CLOUDWATCH_NAMESPACE = 'FooBar Web'QUEUE_TIME_TRACKER_CLOUDWATCH_ACCESS_KEY = 'AK****A'QUEUE_TIME_TRACKER_CLOUDWATCH_SECRET_KEY = 'so******BS'QUEUE_TIME_TRACKER_CLOUDWATCH_REGION = 'us-west-1'azure:QUEUE_TIME_TRACKER_AZURE_REGION = 'eastus'QUEUE_TIME_TRACKER_AZURE_SUBSCRIPTION_ID = '*****'QUEUE_TIME_TRACKER_AZURE_RESOURCE_GROUP_NAME = 'example_group'QUEUE_TIME_TRACKER_AZURE_PROVIDER_NAME = 'Microsoft.ContainerService'QUEUE_TIME_TRACKER_AZURE_RESOURCE_TYPE = 'managedClusters'QUEUE_TIME_TRACKER_AZURE_RESOURCE_ID = 'example-k8s-cluster'Wrap wsgi application with time tracker:
aws:fromrequest_time_tracker.wsgi_django.cloudwatchimportCloudWatchQueueTimeTrackerapplication=get_wsgi_application()application=CloudWatchQueueTimeTracker(application)azure:fromrequest_time_tracker.wsgi_django.azureimportAzureMonitoringQueueTimeTrackerapplication=get_wsgi_application()application=AzureMonitoringQueueTimeTracker(application)Non-django applicationWrap wsgi application with time tracker. Example:fromfunctoolsimportpartialfromrequest_time_tracker.trackers.cache.redisimportRedisCacheQueueTimeTrackerfromrequest_time_tracker.notifiers.cloudwatchimportCloudWatchNotifiertracker=partial(RedisCacheQueueTimeTracker,queue_time_header_name='HTTP_X_REQUESTTIME',redis_url='redis://localhost:6379/0',notifier=CloudWatchNotifier(namespace='FooBar Web',aws_access_key='AK****A',aws_secret_key='so******BS',aws_region='us-west-1',),)wsgi_application=tracker(wsgi_application)Cloudwatch role policy:{
    “Version”: “2012-10-17",
    “Statement”: [
        {
            “Sid”: “VisualEditor0”,
            “Effect”: “Allow”,
            “Action”: [“cloudwatch:PutMetricData”],
            “Resource”: “*”
        }
    ]
}Azurerole definition: Monitoring Metrics Publisherhttps://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#monitoring-metrics-publisher
Package: request-url-2023
IntroductionInstall packagepipinstallrequest-url-2023Example Usage:fromrequest_url_2023importsend_requestssend_requests.run(url="https://www.baidu.com/")Paramsfromrequest_url_2023importsend_requests# 总的请求数# TOTAL_COUNT = 10000# 线程池数目# THREAD_NUM = 20# 每个协程同时发送多少个请求# COROUTINE_REQUEST_COUNT = 50send_requests.run(url="https://www.baidu.com/",TOTAL_COUNT=1000,THREAD_NUM=20,COROUTINE_REQUEST_COUNT=50)
Package: request-validator
Githubhttps://github.com/amirasaran/request_validatorrequest_validatorPython Request(json) Validatorhow to installpip install request_validatorHow to useImaging you have a json response that get from rest api server and youmust validate response.sample:from request_validator.serializers import *
from request_validator.fields import *


class GlossDefSerializer(BaseSerializer):
    para = CharField()
    gloss_see_also = CharField(many=True, source="GlossSeeAlso")


class GlossEntrySerializer(BaseSerializer):
    id = IntField(source="ID")
    sort_as = CharField(source="SortAs")
    gloss_term = CharField(source="GlossTerm")
    acronym = CharField(source="Acronym")
    abbrev = CharField(source="Abbrev", required=True, allow_blank=False)
    gloss_def = GlossDefSerializer(source="GlossDef")
    gloss_see = CharField(source="GlossSee")


class GlossListSerializer(BaseSerializer):
    gloss_entry = GlossEntrySerializer(source="GlossEntry")


class GlossDivSerializer(BaseSerializer):
    title = CharField()
    gloss_list = GlossListSerializer(source="GlossList")


class GlossarySerializer(BaseSerializer):
    title = CharField()
    gloss_div = GlossDivSerializer(source="GlossDiv")


class SampleSerializer(BaseSerializer):
    glossary = GlossarySerializer()


sample_data = {
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": 12,
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": ["GML", "XML"]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
}


validator = SampleSerializer(data=sample_data)
print('validation status:')
print(validator.is_valid())
print("\nvalidation errors:")
print(validator.get_errors())
print("\nvalidated data:")
print(validator.validate_data())The above sample output:validation status:
False

validation errors:
{'glossary': {'gloss_div': {'gloss_list': {'gloss_entry': {'abbrev': ['This field cannot be blank']}}}}}

validated data:
{'glossary': {'title': 'example glossary', 'gloss_div': {'title': 'S', 'gloss_list': {'gloss_entry': {'acronym': 'SGML', 'gloss_term': 'Standard Generalized Markup Language', 'gloss_def': {'gloss_see_also': ['GML', 'XML'], 'para': 'A meta-markup language, used to create markup languages such as DocBook.'}, 'gloss_see': 'markup', 'sort_as': 'SGML', 'id': 12}}}}}
Package: requestwrapper
requestwrapperA simple wrapper for the Python requests packageMotivationCommon use cases when dealing with requests are:handling response errorsrepeating a request until succesfull responseexecuting multiple requestssaving response (html, pdf) to diskRequestwrapper implements simple methods to perform such tasks without having to write your own code.FeaturesParameterize HTTP method using the method-argumentHandle HTTP errors (status_code>299) by returning the raw response instead of jsonRetry failed requests n-timesPrint request-response to consoleSave response content to diskPrerequisitesthe requests module (https://pypi.org/project/requests/)InstallingHosted on PyPI: (https://pypi.org/project/requestwrapper/) With pip: pip install requestwrapperUsageimport requestwrapper.Request
#initialize the Request object
Request0=requestwrapper.Request.Request()

# workhorse function: send_request
res=Request0.send_request(url='https://nu.nl',method='GET')

# save response content to disk
Request0.save_response('nu.txt')ExamplesTODO