繁体   English   中英

Python 2.7中的HTTPS身份验证

[英]HTTPS authentication in Python 2.7

我们正在尝试通过我们的代理传递Virustotal API,但该代理被拒绝了。 使用该代码可以访问HTTP网站,但HTTPS无法通过。 要求任何人张贴一些示例代码,这对我们有帮助。

import postfile
host = "www.virustotal.com"
selector = "https://www.virustotal.com/vtapi/v2/file/scan"
fields = [("apikey", "-- YOUR API KEY --")]
file_to_send = open("test.txt", "rb").read()
files = [("file", "test.txt", file_to_send)]
json = postfile.post_multipart(host, selector, fields, files)
print json

尝试两个想法

1)如果没有HTTPS,则可以发布到http://www.virustotal.com/vtapi/v2/file/scan

2)尝试python请求库

import requests
params = {'apikey': '-YOUR API KEY HERE-'}
files = {'file': ('myfile.exe', open('myfile.exe', 'rb'))}
response = requests.post('https://www.virustotal.com/vtapi/v2/file/scan', files=files, params=params)
json_response = response.json()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM