viết bacth trong poweshell để tự động lấy dữ liệu theo thông tin…
- User
viết bacth trong poweshell để tự động lấy dữ liệu theo thông tin fetch(“https://iboard-query.ssi.com.vn/v2/stock/exchange/hose”, { “headers”: { “accept”: “application/json, text/plain, /”, “accept-language”: “vi”, }, “referrer”: “https://iboard.ssi.com.vn/”, “referrerPolicy”: “strict-origin-when-cross-origin”, “body”: null, “method”: “GET”, “mode”: “cors”, “credentials”: “omit” });
- Assistant
Trong PowerShell, bạn có thể sử dụng
Invoke-RestMethodđể thực hiện các yêu cầu HTTP GET mà không cần một file batch theo nghĩa truyền thống. Dưới đây là một đoạn script PowerShell mà bạn có thể sử dụng để tự động hóa việc fetch dữ liệu từ URL cung cấp:powershell# Đặt URL mà bạn muốn fetch dữ liệu từ đó $url = "https://iboard-query.ssi.com.vn/v2/stock/exchange/hose" # Thiết lập các headers $headers = @{ "accept" = "application/json, text/plain, */*" "accept-language" = "vi" } # Thiết lập các tham số khác $referrer = "https://iboard.ssi.com.vn/" $referrerPolicy = "strict-origin-when-cross-origin" $body = $null $method = "GET" $mode = "cors" $credentials = "omit" # Thực hiện yêu cầu GET $response = Invoke-RestMethod -Uri $url -Method $method -Headers $headers # In ra kết quả $response | ConvertTo-Json -Depth 10