-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
who know how to add proxy and request #3262
Comments
smth like this one for rest requests @classmethod
def sendRequest(
cls, host, port, path, headers, params, reqType="GET", preview=False
):
proxy_uri = "http://username:password@host:port"
logger.debug(
"sendRequest(host=%s, port=%s, path=%s, headers=%s, params=%s, reqType=%s, preview=%s)"
% (host, port, path, headers, params, reqType, preview)
)
params = cls.urlencodeParams(params)
path = path + "?" + params if reqType == "GET" and params else path
if not preview:
logger.debug("Opening connection to %s" % host)
url = urlparse(proxy_uri)
conn = httplib.HTTPSConnection(url.hostname, url.port)
if url.username and url.password:
auth = "%s:%s" % (url.username, url.password)
headers[
"Proxy-Authorization"
] = "Basic " + base64.b64encode(auth.encode()).decode("ascii")
conn.set_tunnel(host, port, headers)
else:
logger.debug(
"Should open connection to %s, but this is a preview" % host
)
conn = None
if not preview:
logger.debug("Sending %s request to %s" % (reqType, path))
conn.request(reqType, path, params, headers)
else:
logger.debug(
"Should send %s request to %s, but this is a preview"
% (reqType, path)
)
return None
response = conn.getresponse()
return response |
D 2024-05-02 22:35:24,280 yowsup.common.http.warequest - Opening connection
to v.whatsapp.net
Traceback (most recent call last):
File "C:\Users\60113\Desktop\自动注册WA\个人版\yowsup-cli", line 722, in <module>
if not parser.process():
^^^^^^^^^^^^^^^^
File "C:\Users\60113\Desktop\自动注册WA\个人版\yowsup-cli", line 387, in process
self.handleRequestCode(self.args["requestcode"], config)
File "C:\Users\60113\Desktop\自动注册WA\个人版\yowsup-cli", line 399, in
handleRequestCode
result = codeReq.send(encrypt=self._encrypt, preview=self._preview)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"C:\Users\60113\Desktop\自动注册WA\个人版\yowsup\registration\coderequest.py",
line 46, in send
res = super(WACodeRequest, self).send(parser, encrypt=encrypt,
preview=preview)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\60113\Desktop\自动注册WA\个人版\yowsup\common\http\warequest.py",
line 150, in send
return self.sendGetRequest(parser, encrypt, preview=preview)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\60113\Desktop\自动注册WA\个人版\yowsup\common\http\warequest.py",
line 222, in sendGetRequest
self.response = WARequest.sendRequest(host, port, path, headers,
params, "GET", preview=preview)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\60113\Desktop\自动注册WA\个人版\yowsup\common\http\warequest.py",
line 311, in sendRequest
url = urlparse(proxy_uri)
^^^^^^^^
NameError: name 'urlparse' is not defined
…On Thu, 2 May 2024 at 21:54, benhacka ***@***.***> wrote:
smth like this one for code request
@classmethoddef sendRequest(
cls, host, port, path, headers, params, reqType="GET", preview=False
):
proxy_uri = ***@***.***:port"
logger.debug(
"sendRequest(host=%s, port=%s, path=%s, headers=%s, params=%s, reqType=%s, preview=%s)"
% (host, port, path, headers, params, reqType, preview)
)
params = cls.urlencodeParams(params)
path = path + "?" + params if reqType == "GET" and params else path
if not preview:
logger.debug("Opening connection to %s" % host)
url = urlparse(proxy_uri)
conn = httplib.HTTPSConnection(url.hostname, url.port)
if url.username and url.password:
auth = "%s:%s" % (url.username, url.password)
headers[
"Proxy-Authorization"
] = "Basic " + base64.b64encode(auth.encode()).decode("ascii")
conn.set_tunnel(host, port, headers)
else:
logger.debug(
"Should open connection to %s, but this is a preview" % host
)
conn = None
if not preview:
logger.debug("Sending %s request to %s" % (reqType, path))
conn.request(reqType, path, params, headers)
else:
logger.debug(
"Should send %s request to %s, but this is a preview"
% (reqType, path)
)
return None
response = conn.getresponse()
return response
—
Reply to this email directly, view it on GitHub
<#3262 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIVADAQZWWWXNPTLT5OYO2TZAJAR7AVCNFSM6AAAAABHCYWMZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJQGU3DAOBUGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
try:
# py3
from urllib.parse import urlparse
except ImportError:
# py2
from urlparse import urlparse |
Traceback (most recent call last): |
No description provided.
The text was updated successfully, but these errors were encountered: