httpQuery() [v0.3.5]

作者: DerRaphael 最近更新时间: 20080828


This is a small function for handling POST and GET queries natively in AHK so external utilities to handle it are not needed any more. It can be used where no additional utilities, such as cURL or wget are wanted.
The latest version handles following features:

* ports in URL
* Username:Password@domain style URLs (see this answer to avoid common problems)
* SSL aka https
* HeaderInformations / Dumping / Storing
* DownloadSizes / CurrentSize (for download progressbars)
* Flags for InternetConnection handling (auto follow feature etc)
* Referrer for Queries
* Accepttypes for Queries
* Proxy handling
* timeout handling
* custom UserAgent

httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")

关于函数的参数和返回值, 请参阅其源码或 此文档.

备注

The library is not strictly stdlib conform, because it makes use of some global variables.

The documentation is copied part from author`s forum post about the library.

关于此函数(集)的更新细节和注意事项, 请参见 AutoHotkey 论坛: http://www.autohotkey.com/forum/topic33506.html

许可

此函数(集)是基于 zLib-Style 许可的开源项目. 想了解许可详情, 请参见 http://en.wikipedia.org/wiki/Zlib_License

示例

; #Include httpQuery.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

; exmpl.searchAHKforum.httpQuery.ahk
; Searches the forum for a given Phrase: in this case httpQuery
#noenv
html     := ""
URL      := "http://www.autohotkey.com/forum/search.php?mode=results"
POSTData := "search_keywords=httpQuery&search_terms=all&search_forum=-1&"
          . "search_time=0&search_fields=all&show_results=topics&return_chars=500"
          . "&sort_by=0&sort_dir=DESC"

length := httpQuery(html,URL,POSTdata)
varSetCapacity(html,-1)

Gui,Add,Edit,w600 +Wrap r25,% html
Gui,Show
Return

GuiClose:
GuiEscape:
   ExitApp