ImportError: No module named ‘Queue’ [duplicate]
import queue is lowercase q in Python 3. Change Q to q and it will be fine. (See code in https://stackoverflow.com/a/29688081/632951 for smart switching.)
import queue is lowercase q in Python 3. Change Q to q and it will be fine. (See code in https://stackoverflow.com/a/29688081/632951 for smart switching.)
Alternatively, you can use requests.Session and observe cookies before and after a request: >>> import requests >>> session = requests.Session() >>> print(session.cookies.get_dict()) {} >>> response = session.get(‘http://google.com’) >>> print(session.cookies.get_dict()) {‘PREF’: ‘ID=5514c728c9215a9a:FF=0:TM=1406958091:LM=1406958091:S=KfAG0U9jYhrB0XNf’, ‘NID’: ’67=TVMYiq2wLMNvJi5SiaONeIQVNqxSc2RAwVrCnuYgTQYAHIZAGESHHPL0xsyM9EMpluLDQgaj3db_V37NjvshV-eoQdA8u43M8UwHMqZdL-S2gjho8j0-Fe1XuH5wYr9v’}
This snippet of code will make all HTTP requests from the same session retry for a total of 5 times, sleeping between retries with an increasing backoff of 0s, 2s, 4s, 8s, 16s (the first retry is done immediately). It will retry on basic connectivity issues (including DNS lookup failures), and HTTP status codes of … Read more
Lovoo is using OAuth 1 protocol (https://tools.ietf.org/html/draft-hammer-oauth-10). I have previously worked with the Lovoo API. One thing I can say is that your account will soon get limited by their BOT detection algorithms. I didn’t try with different combinations of HTTP headers. Hence, that may be worth the try. However, I have published my work … Read more
It is indeed possible. Here is an example calling the Weather SOAP Service using plain requests lib: import requests url=”http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL” #headers = {‘content-type’: ‘application/soap+xml’} headers = {‘content-type’: ‘text/xml’} body = “””<?xml version=”1.0″ encoding=”UTF-8″?> <SOAP-ENV:Envelope xmlns:ns0=”http://ws.cdyne.com/WeatherWS/” xmlns:ns1=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”> <SOAP-ENV:Header/> <ns1:Body><ns0:GetWeatherInformation/></ns1:Body> </SOAP-ENV:Envelope>””” response = requests.post(url,data=body,headers=headers) print response.content Some notes: The headers are important. Most SOAP requests … Read more
The Response object returned by requests.post() (and requests.get() etc.) has a property called elapsed, which provides the time delta between the Request was sent and the Response was received. To get the delta in seconds, use the total_seconds() method: response = requests.post(url, data=post_fields, timeout=timeout) print(response.elapsed.total_seconds()) Note that requests.post() is a synchronous operation, which means that … Read more
From https://stackoverflow.com/a/33717517/1695680 To make python requests use the system ca-certificates bundle, it needs to be told to use it over its own embedded bundle export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt Requests embeds its bundles here, for reference: /usr/local/lib/python2.7/site-packages/requests/cacert.pem /usr/lib/python3/dist-packages/requests/cacert.pem Or in newer versions use additional package to obtain certificates from: https://github.com/certifi/python-certifi To verify from which file certificates are loaded, … Read more
The modern way: pip install -U ‘requests[socks]’ then import requests resp = requests.get(‘http://go.to’, proxies=dict(http=’socks5://user:pass@host:port’, https=”socks5://user:pass@host:port”))
You can use a session object. It stores the cookies so you can make requests, and it handles the cookies for you s = requests.Session() # all cookies received will be stored in the session object s.post(‘http://www…’,data=payload) s.get(‘http://www…’) Docs: https://requests.readthedocs.io/en/master/user/advanced/#session-objects You can also save the cookie data to an external file, and then reload them … Read more
You need to use a session object and send the authentication each request. The session will also track cookies for you: session = requests.Session() session.auth = (user, password) auth = session.post(‘http://’ + hostname) response = session.get(‘http://’ + hostname + ‘/rest/applications’)