Kirim permintaan HTTP.
Mengembalikan data tindak balas permintaan.JSON
string, ia boleh dianalisis olehJSON.parse()
fungsi dalamJavaScript
strategi bahasa, dan olehjson::parse()
fungsi dalamC++
Jika debug ditetapkan kepada benar dalam struktur pilihan, nilai pulangan adalah objek (JSON); jika debug ditetapkan kepada palsu, nilai pulangan adalah rentetan.
senar, objek
HttpQuery ((url) HttpQuery ((url, pilihan)
URL permintaan HTTP. url betul senar Seting yang berkaitan dengan permintaan HTTP, misalnya, boleh disusun seperti berikut:
{
method: "POST",
body: "a=10&b=20&c=30",
charset: "UTF-8",
cookie: "session_id=12345; lang=en",
profile: "chrome_103",
debug: false,
headers: {"TEST-HTTP-QUERY": "123"},
timeout: 1000
}
tls
cap jari.
Tetapan yang disokong termasuk pilihan berikut:
chrome_:"chrome_103"
, "chrome_104"
, "chrome_105"
, "chrome_106"
, "chrome_107"
, "chrome_108"
, "chrome_109"
, "chrome_110"
, "chrome_111"
, "chrome_112"
, "chrome_117"
...
Safari_:"safari_15_6_1"
, "safari_16_0"
, "safari_ipad_15_6"
, "safari_ios_15_5"
, "safari_ios_15_6"
, "safari_ios_16_0"
...
Firefox_:"firefox_102"
, "firefox_104"
, "firefox_105"
, "firefox_106"
, "firefox_108"
, "firefox_110"
, "firefox_117"
...
Opera_:"opera_89"
, "opera_90"
, "opera_91"
...
Zalando:"zalando_android_mobile"
, "zalando_ios_mobile"
...
Nike_:"nike_ios_mobile"
, "nike_android_mobile"
...
pencakar awan:"cloudscraper"
...
mms_:"mms_ios"
...
mesh_:"mesh_ios"
, "mesh_ios_1"
, "mesh_ios_2"
, "mesh_android"
, "mesh_android_1"
, "mesh_android_2"
...
Diperakui:"confirmed_ios"
, "confirmed_android"
...
ok."okhttp4_android_7"
, "okhttp4_android_8"
, "okhttp4_android_9"
, "okhttp4_android_10"
, "okhttp4_android_11"
, "okhttp4_android_12"
, "okhttp4_android_13"
,true
, yangHttpQuery
panggilan fungsi mengembalikan mesej jawapan penuh.false
, hanya data dalamBody
daripada mesej jawapan dikembalikan.profile
medan boleh ditinggalkan.pilihan palsu objek
function main(){
// An example of GET access without parameters
var info = JSON.parse(HttpQuery("https://www.okx.com/api/v5/public/time"))
Log(info)
// An example of GET access with parameters
var ticker = JSON.parse(HttpQuery("https://www.okx.com/api/v5/market/books?instId=BTC-USDT"))
Log(ticker)
}
import json
import urllib.request
def main():
# HttpQuery does not support Python, you can use the urllib/urllib2 library instead
info = json.loads(urllib.request.urlopen("https://www.okx.com/api/v5/public/time").read().decode('utf-8'))
Log(info)
ticker = json.loads(urllib.request.urlopen("https://www.okx.com/api/v5/market/books?instId=BTC-USDT").read().decode('utf-8'))
Log(ticker)
void main() {
auto info = json::parse(HttpQuery("https://www.okx.com/api/v5/public/time"));
Log(info);
auto ticker = json::parse(HttpQuery("https://www.okx.com/api/v5/market/books?instId=BTC-USDT"));
Log(ticker);
}
Contoh mengakses antara muka API ticker awam OKX.
function main() {
// Setting proxy and sending an http request for this time, no username, no password, this http request will be sent through the proxy
HttpQuery("socks5://127.0.0.1:8889/http://www.baidu.com/")
// Setting proxy and sending an http request for this time, enter the user name and password, only the current call to HttpQuery takes effect, and then call HttpQuery again ("http://www.baidu.com") so that the proxy will not be used.
HttpQuery("socks5://username:password@127.0.0.1:8889/http://www.baidu.com/")
}
# HttpQuery does not support Python, you can use the urllib/urllib2 library instead
void main() {
HttpQuery("socks5://127.0.0.1:8889/http://www.baidu.com/");
HttpQuery("socks5://username:password@127.0.0.1:8889/http://www.baidu.com/");
}
Fungsi HttpQuery menggunakan tetapan proksi.
PeraturanHttpQuery()
fungsi hanya menyokongJavaScript
, C++
bahasa,Python
bahasa boleh menggunakanurllib
perpustakaan untuk menghantar permintaan Http secara langsung.HttpQuery()
digunakan terutamanya untuk mengakses antara muka pertukaran yang tidak memerlukan tandatangan, seperti antara muka awam seperti maklumat ticker.HttpQuery()
boleh digunakan dalam sistem backtesting untuk menghantar permintaan (hanyaGET
Percubaan belakang terhad kepada menggunakan 20 lawatan keURLs
, danHttpQuery()
kunjungan akan cache data.URL
diperolehi untuk kali kedua,HttpQuery()
fungsi mengembalikan data yang disimpan dan tiada lagi permintaan rangkaian sebenar berlaku.
{@fun/Global/HttpQuery_Go HttpQuery_Go}
Pilih HttpQuery_Go