我可以使用 pycurl 请求向服务器发送自定义标头(例如“yaddayadda”)吗?
Can I send a custom header like "yaddayadda" to the server with the pycurl request?
我会编写如下代码:
pycurl_connect = pycurl.Curl() pycurl_connect.setopt(pycurl.URL, your_url) pycurl_connect.setopt(pycurl.HTTPHEADER, ['header_name1: header_value1', 'header_name2: header_value2']) pycurl_connect.perform()
I would code something like:
您可以使用 HTTPHEADER。只需以列表形式提供自定义标头,如下所示:
header = ['test: yadayadayada', 'blahblahblah']
curl.setopt(pycurl.HTTPHEADER, header)
you can, with HTTPHEADER. just provide your custom headers as a list, like so:
尝试使用 human_curl 库 https://github.com/Lispython/ human_curl
custom_headers = ( ('Test-Header', 'fwkjenwkljbnfkjqnewfrjven3lrf'), ('Another-Header', 'ifenwqnfe;wnfqfjlweqnnlf') ) r = human_curl.get("http://stackoverflow.com", headers=custom_headers)
Try to use human_curl library https://github.com/Lispython/human_curl
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
我会编写如下代码:
I would code something like:
您可以使用 HTTPHEADER。只需以列表形式提供自定义标头,如下所示:
header = ['test: yadayadayada', 'blahblahblah']
curl.setopt(pycurl.HTTPHEADER, header)
you can, with HTTPHEADER. just provide your custom headers as a list, like so:
header = ['test: yadayadayada', 'blahblahblah']
curl.setopt(pycurl.HTTPHEADER, header)
尝试使用 human_curl 库 https://github.com/Lispython/ human_curl
Try to use human_curl library https://github.com/Lispython/human_curl