python win32com how to set winhttp option value

大憨熊 提交于 2020-01-02 13:08:28

问题


from win32com.client import Dispatch

winhttp = Dispatch('winhttp.winhttprequest.5.1')

print winhttp.Option(6) #True

winhttp.Option(6) = False #SyntaxError  <----------------how to set Option(6) to false

print winhttp.Option(6)

winhttp.Open('GET', 'http://google.com', False)
winhttp.Send()

print winhttp.responsetext

===========================================

output:

invalid syntax: winhttp.py, line 13, pos 11 File "c:\Users\***\Desktop\winhttp.py", line 13, in ? set winhttp.Option(6) = False

how to do it? many thanks!


回答1:


This should work:

winhttp.SetOption(6, False)

Unless you have some really good reason for using winhttprequest, I'd use something out of the Python standard library, or better yet install the requests library. You will find these options much easier to deal with.



来源:https://stackoverflow.com/questions/14417539/python-win32com-how-to-set-winhttp-option-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!