Bắt đầu
Giải thích tham số
Tham số | Kiểu | Mô tả |
---|---|---|
actor | string | Một tham số rất quan trọng, nó đại diện cho một dịch vụ. Nhấp để xem thông tin danh sách actor scraper |
input | object | Các tham số cần thiết bởi actor để hoàn thành tác vụ thu thập dữ liệu. |
proxy | object | Trường country, sử dụng proxy từ khu vực này để gửi yêu cầu. |
Giải thích trường Input
Tham số | Kiểu | Mặc định | Mô tả |
---|---|---|---|
url | string | Website mục tiêu | |
method | string | GET | Phương thức yêu cầu |
redirect | boolean | false | Cho phép chuyển hướng hay không |
headers | object | Các trường header yêu cầu tùy chỉnh |
Gửi yêu cầu đầu tiên
Sử dụng việc thu thập dữ liệu của https://httpbin.io/get
làm ví dụ.
Thu thập dữ liệu thông qua điểm cuối API
import requests
import json
API_KEY = ""
host = "api.scrapeless.com"
url = f"https://{host}/api/v1/unlocker/request"
payload = json.dumps({
"actor": "unlocker.webunlocker",
"input": {
"url": "https://httpbin.io/get",
"redirect": False,
"method": "GET",
},
"proxy":{
"country": "ANY",
}
})
headers = {
'Content-Type': 'application/json',
'x-api-token': f'{API_KEY}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)