はじめに
パラメータの説明
パラメータ | 型 | 説明 |
---|---|---|
actor | string | 非常に重要なパラメータです。サービスを表します。スクレーパーのアクターリスト情報を見るにはクリックしてください |
input | object | データスクレイピングタスクを完了するためにアクターが必要とするパラメータ。 |
proxy | object | countryフィールド。この地域のプロキシを使用してリクエストを送信します。 |
入力フィールドの説明
パラメータ | 型 | デフォルト | 説明 |
---|---|---|---|
url | string | ターゲットウェブサイト | |
method | string | GET | リクエストメソッド |
redirect | boolean | false | リダイレクトを許可するかどうか |
headers | object | カスタムリクエストヘッダーフィールド |
最初のリクエストを送信する
https://httpbin.io/get
のデータスクレイピングを例として使用します。
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)