Introduction
- 株式会社マーズフラッグ が提供する API のドキュメントです。
- 内容の予告なく変更されることがあります。
Authorization
- MP Crawler API v1.0(on MF3) の利用の際は API キー(x-mf-apikey)の設定が必要です。
- API キーは MARS Platform 上の管理画面にて事前に発行された値を API 実行時のリクエストヘッダーに設定します。
- キー名:x-mf-apikey
INSTANT CRAWLER API v1
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
- クローラに関連するAPIドキュメントを記載。
- 以下は第2回PoC時点ではマーズ側にて事前に設定しておく。
- API実行時のエンドポイント、APIキー、Webhookの設定が必要(最終的には管理画面よりお客様にて管理)。
- APIのパスに含まれる以下パスパラメータは本APIのURL発行時に確定する。
- {contract_id}
- {servicegroup_id}
Base URLs:
instant_crawl_status
インスタントクロール実行状態取得
Code samples
const headers = {
'Accept':'application/json',
'X-Request-ID':'string',
'x-mf-apikey':'string'
};
fetch('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/statuses',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': 'application/json',
'X-Request-ID': 'string',
'x-mf-apikey': 'string'
}
r = requests.get('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/statuses', headers = headers)
print(r.json())
GET /contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/statuses
クロールリクエストAPI実行時に発行されるinstant_crawl_request_idについて、現在の実行状態を取得する。 完了しているinstant_crawl_request_idについては本APIは空を返す。 クロールが完了すると、実行状態データはクリアされ、実行履歴にデータが記録される。
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
X-Request-ID | header | string | false | リクエストID |
instant_crawl_request_ids | query | string | false | インスタントクローラ実行要求Id群。カンマ区切りにて複数指定可能。例:1,2,3 |
x-mf-apikey | header | string | false | API KEY |
contract_id | path | integer | true | 契約Id |
servicegroup_id | path | integer | true | サービスグループId |
Example responses
200 Response
{
"message": "string",
"crawl_status": {
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | GetInstantCrawlStatusesRes |
インスタントクロール実行キャンセル
Code samples
const headers = {
'Accept':'application/json',
'X-Request-ID':'string',
'x-mf-apikey':'string'
};
fetch('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/statuses/requests/{instant_crawl_request_id}/cancel',
{
method: 'PUT',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': 'application/json',
'X-Request-ID': 'string',
'x-mf-apikey': 'string'
}
r = requests.put('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/statuses/requests/{instant_crawl_request_id}/cancel', headers = headers)
print(r.json())
PUT /contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/statuses/requests/{instant_crawl_request_id}/cancel
クロールリクエスト実行時に発行されるinstant_crawl_request_idに対応するクロール実行についてキャンセルする。 キャンセル後にしばらくしてクローラは終了する。キャンセルした場合はクロール成果物は作製されない。
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
X-Request-ID | header | string | false | リクエストID |
x-mf-apikey | header | string | false | API KEY |
contract_id | path | integer | true | 契約Id |
servicegroup_id | path | integer | true | サービスグループId |
instant_crawl_request_id | path | integer | true | インスタントクローラ実行要求Id |
Example responses
200 Response
{
"message": "string",
"status": "string",
"crawl_status": {
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | CancelInstantCrawlRes |
instant_crawl_request
インスタントクロール実行要求
Code samples
const inputBody = '{
"setting": {
"seed_urls": [
"https://crawl-test4.marsflag.com/"
],
"documents_limit": 1000,
"crawl_result_collection": {
"crawl_object": 1
}
}
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'X-Request-ID':'string',
'x-mf-apikey':'string'
};
fetch('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/request',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Request-ID': 'string',
'x-mf-apikey': 'string'
}
r = requests.post('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/request', headers = headers)
print(r.json())
POST /contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/request
- クロールの実行を依頼する。
- クロール実行は本API実行後、非同期で実行される。
Body parameter
{
"setting": {
"seed_urls": [
"https://crawl-test4.marsflag.com/"
],
"documents_limit": 1000,
"crawl_result_collection": {
"crawl_object": 1
}
}
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
X-Request-ID | header | string | false | リクエストID |
x-mf-apikey | header | string | true | API KEY |
body | body | RequestInstantCrawlReq | false | none |
contract_id | path | integer | true | 契約Id |
servicegroup_id | path | integer | true | サービスグループId |
Example responses
OK
{
"message": "SUCCESS",
"status": "OK",
"instant_crawl_request_id": 999
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | RequestInstantCrawlRes |
Response Headers
Status | Header | Type | Format | Description |
---|---|---|---|---|
200 | X-Request-ID | string | リクエストID |
インスタントクロール履歴取得
Code samples
const headers = {
'Accept':'application/json',
'X-Request-ID':'string',
'x-mf-apikey':'string'
};
fetch('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/histories',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': 'application/json',
'X-Request-ID': 'string',
'x-mf-apikey': 'string'
}
r = requests.get('https://instant-crawler.api.mf3.marsflag.com/api/v1/contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/histories', headers = headers)
print(r.json())
GET /contracts/{contract_id}/servicegroups/{servicegroup_id}/crawler/histories
- コントラクトクId/サービスグループIdに紐づくクロール実行履歴を取得する。
- 作成日時の降順に取得し、上位10件を取得する。
- instant_crawl_request_idを指定することで該当のクロール実行要求に限定(1件のみ)して検索できる。
- 以下、クロール実行状態種別id/クロール実行状態種別名の一覧。
status_id | status_name | description1 | description2 |
---|---|---|---|
2010 | pending | 未稼働 | 本APIでは利用しない |
2020 | running | 稼働 | 本APIでは利用しない |
2030 | stopped | 停止 | 正常終了 |
2040 | troubled | 障害 | 異常終了 |
2050 | stopped_by_cancel | キャンセルによる停止 | キャンセル(クローラ成果物は作成されない) |
2060 | stopped_by_timeout | タイムアウトによる停止 | タイムアウトによる停止(クローラ成果物は作成されない) |
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
from_datetime | query | string | false | クロール実行日時From(フォーマット:yyyy-MM-ddTHH:mm:ss+NN:NN) |
to_datetime | query | string | false | クロール実行日時To(フォーマット:yyyy-MM-ddTHH:mm:ss+NN:NN) |
instant_crawl_request_id | query | integer | false | インスタントクローラ実行要求Id |
X-Request-ID | header | string | false | リクエストID |
x-mf-apikey | header | string | false | API KEY |
contract_id | path | integer | true | 契約Id |
servicegroup_id | path | integer | true | サービスグループId |
Example responses
OK
{
"message": "SUCCESS",
"status": "OK",
"crawl_histories": [
{
"id": 111,
"instant_crawl_request_id": 999,
"crawl_execution_status_dtype_id": 2030,
"crawl_execution_status_dtype_name": "停止",
"is_cancel_request": false,
"start_datetime": "2021-07-01T11:22:33.123456+00:00",
"end_datetime": "2021-07-02T22:33:44.123456+00:00",
"crawled_url_count": 1000,
"total_url_count": 2000,
"crawl_url_list_path": "https://dl.blue.api.mf3stg.marsflag.com/instant_crawler/contracts/999/servicegroups/888/instant_crawl_requests/777/"
}
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | GetInstantCrawlerHistoriesRes |
Response Headers
Status | Header | Type | Format | Description |
---|---|---|---|---|
200 | X-Request-ID | string | リクエストID |
Schemas
Screenshot
{
"viewport_width": 1336,
"viewport_height": 768,
"render_all": false
}
Screenshot
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
viewport_width | integer¦null | false | none | viewportのwidth |
viewport_height | integer¦null | false | none | viewportのheight |
render_all | boolean¦null | false | none | スクリーンショットをフルサイズで取得するかの設定(画面表示領域外も含める) |
Authorization
{
"type": "BASIC",
"url_pattern": "string",
"user": "string",
"password": "string"
}
Authorization
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
type | string¦null | false | none | 認証種別(現行では指定不要) 現行はBASIC固定 |
url_pattern | string¦null | false | none | 設定を利用するURLの正規表現(現行では指定不要) |
user | string¦null | false | none | ユーザー |
password | string¦null | false | none | パスワード |
Schedule
{
"interval": 0,
"min": 0,
"hour": 0,
"day_of_week": 0,
"day_of_month": 0
}
schedule
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
interval | integer¦null | true | none | none |
min | integer¦null | true | none | none |
hour | integer¦null | true | none | none |
day_of_week | integer¦null | true | none | none |
day_of_month | integer¦null | true | none | none |
CrawlFile
{
"pdf": 0,
"ms_office": 0
}
CrawlFile
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
integer¦null | false | none | クロール対象としてPDFを含める * 0:含めない * 1:含む |
|
ms_office | integer¦null | false | none | クロール対象としてMS-Office系ファイルを含める * 0:含めない * 1:含む |
Enumerated Values
Property | Value |
---|---|
0 | |
1 | |
ms_office | 0 |
ms_office | 1 |
CrawlResultCollection
{
"crawl_object": 1,
"url_list": 1,
"link_url_list": 0
}
CrawlResultCollection
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
crawl_object | integer¦null | false | none | クロールしたページのHTMLを集計する * 0:集計する * 1:集計しない |
url_list | integer¦null | false | none | クロールしたURLを集計する * 0:集計する * 1:集計しない |
link_url_list | integer¦null | false | none | ページ毎に取得したリンクを集計する(現状は利用不可) * 0:集計する * 1:集計しない |
Enumerated Values
Property | Value |
---|---|
crawl_object | 0 |
crawl_object | 1 |
url_list | 0 |
url_list | 1 |
link_url_list | 0 |
link_url_list | 1 |
RequestFingerprint
{
"keep_query": 1,
"keep_fragment": 0
}
RequestFingerprint
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
keep_query | integer¦null | false | none | クエリパラメータを含めるかの設定 * 0:含めない * 1:含める |
keep_fragment | integer¦null | false | none | フラグメント(ハッシュ)パラメータを含めるかの設定 ※SPA利用の際は有効にしてください * 0:含めない * 1:含める |
Enumerated Values
Property | Value |
---|---|
keep_query | 0 |
keep_query | 1 |
keep_fragment | 0 |
keep_fragment | 1 |
InstantCrawlerSetting
{
"version": "1.0.0",
"crawl_file": {
"pdf": 0,
"ms_office": 0
},
"crawl_result_collection": {
"crawl_object": 1,
"url_list": 1,
"link_url_list": 0
},
"request_fingerprint": {
"keep_query": 1,
"keep_fragment": 0
},
"user_agent": "string",
"seed_urls": [
"string"
],
"allow_urls_patterns": [
"string"
],
"deny_urls_patterns": [
"string"
],
"documents_limit": 100,
"timezone": "string",
"language": "string",
"screenshot": {
"viewport_width": 1336,
"viewport_height": 768,
"render_all": false
},
"depth_limit": 5,
"authorizations": [
{
"type": "BASIC",
"url_pattern": "string",
"user": "string",
"password": "string"
}
],
"robots_txt": true,
"wait_type": 0,
"base_concurrent_requests": 1,
"download_delay": 0,
"execution_timeout": 0
}
InstantCrawlerSetting
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
version | string¦null | false | none | クローラ設定バージョン 指定しない場合、サーバー側で最新バージョンとして解釈される。 |
crawl_file | CrawlFile | false | none | * インスタントクローラーの設定モデル。 * HTML以外のファイルをクロール対象とするか設定。 |
crawl_result_collection | CrawlResultCollection | false | none | * インスタントクローラーの設定モデル。 * クロール成果物として収集する設定。 |
request_fingerprint | RequestFingerprint | false | none | * インスタントクローラーの設定モデル。 * クロール時のURLパラメータを利用設定。 |
user_agent | string¦null | false | none | クロール時のユーザーエージェント(現状では指定不要) |
seed_urls | [string] | true | none | 起点URL |
allow_urls_patterns | [string]¦null | false | none | 許可URL 指定しない場合は、seed_urlsからドメインに限定した条件が自動設定される。 |
deny_urls_patterns | [string]¦null | false | none | 除外URL |
documents_limit | integer¦null | false | none | クロールドキュメント数制限 ドキュメント(ページ)を取得する制限値 |
timezone | string¦null | false | none | タイムゾーン(現状では指定不要) |
language | string¦null | false | none | ランゲージ(現状では指定不要) |
screenshot | Screenshot | false | none | * インスタントクローラーの設定モデル。 * スクリーンショットの設定。 |
depth_limit | integer¦null | false | none | ホップ数制限 ページからリンクを辿る回数 |
authorizations | [Authorization]¦null | false | none | 認証情報(現状はBASIC認証) 複数指定可能ですが、現在は最初1設定のみ有効 |
robots_txt | boolean¦null | false | none | robots_txtに従ってクロールするかの設定 |
wait_type | integer¦null | false | none | ページ表示完了待機種別 * 0: 通常(デフォルト) * 1: 予約(現行利用しない) * 2: SPA向け * 3: 予約(現行利用しない) |
base_concurrent_requests | integer¦null | false | none | 同時接続数 |
download_delay | number¦null | false | none | リクエスト間隔 |
execution_timeout | integer¦null | false | none | クロールの最大実行時間(秒) * 規定値86400秒(1日) * 最大値259200秒(3日) |
CrawlStatus
{
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0
}
CrawlStatus
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | integer | false | none | クロール実行状態id(システム内部で利用) |
instant_crawl_request_id | integer | false | none | インスタントクロール実行要求Id |
crawl_execution_status_dtype_id | integer | false | none | クロール実行状態種別id(API概要記載の表を参照) |
crawl_execution_status_dtype_name | string | false | none | クロール実行状態種別名(API概要記載の表を参照) |
is_cancel_request | boolean | false | none | キャンセル要求有無フラグ(キャンセルの場合にtrue) |
start_datetime | string | false | none | クロール開始時刻(フォーマット:yyyy-MM-ddTHH:mm:ss.SSSSSS+NN:NN) |
end_datetime | string | false | none | クロール終了時刻(フォーマット:yyyy-MM-ddTHH:mm:ss.SSSSSS+NN:NN) |
crawled_url_count | integer | false | none | none |
total_url_count | integer | false | none | none |
CrawlHistory
{
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0,
"crawl_url_list_path": "string"
}
CrawlHistory
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | integer | false | none | クロール実行履歴id(システム内部で利用) |
instant_crawl_request_id | integer | false | none | インスタントクロール実行要求Id |
crawl_execution_status_dtype_id | integer | false | none | クロール実行状態種別id(API概要記載の表を参照) |
crawl_execution_status_dtype_name | string | false | none | クロール実行状態種別名(API概要記載の表を参照) |
is_cancel_request | boolean | false | none | キャンセル要求有無フラグ(キャンセルの場合にtrue) |
start_datetime | string | false | none | クロール開始時刻(フォーマット:yyyy-MM-ddTHH:mm:ss.SSSSSS+NN:NN) |
end_datetime | string | false | none | クロール終了時刻(フォーマット:yyyy-MM-ddTHH:mm:ss.SSSSSS+NN:NN) |
crawled_url_count | integer | false | none | none |
total_url_count | integer | false | none | none |
crawl_url_list_path | string | false | none | クロール全体の成果物パス。成果物を作成していない、または作成に失敗時は「-」を設定。 |
InstantCrawlRequest
{
"id": 0,
"contract_id": 0,
"servicegroup_id": 0,
"setting": {
"version": "1.0.0",
"crawl_file": {
"pdf": 0,
"ms_office": 0
},
"crawl_result_collection": {
"crawl_object": 1,
"url_list": 1,
"link_url_list": 0
},
"request_fingerprint": {
"keep_query": 1,
"keep_fragment": 0
},
"user_agent": "string",
"seed_urls": [
"string"
],
"allow_urls_patterns": [
"string"
],
"deny_urls_patterns": [
"string"
],
"documents_limit": 100,
"timezone": "string",
"language": "string",
"screenshot": {
"viewport_width": 1336,
"viewport_height": 768,
"render_all": false
},
"depth_limit": 5,
"authorizations": [
{
"type": "BASIC",
"url_pattern": "string",
"user": "string",
"password": "string"
}
],
"robots_txt": true,
"wait_type": 0,
"base_concurrent_requests": 1,
"download_delay": 0,
"execution_timeout": 0
},
"request_received_datetime": "string",
"created_datetime": "string",
"updated_datetime": "string"
}
InstantCrawlRequest
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | integer | false | none | クロール実行要求Id |
contract_id | integer | false | none | 契約Id |
servicegroup_id | integer | false | none | サービスグループId |
setting | InstantCrawlerSetting | false | none | * インスタントクローラーの設定モデル。 * すべての設定項目を指定する必要はない。 |
request_received_datetime | string | false | none | 要求受付日時 |
created_datetime | string | false | none | 作成日時 |
updated_datetime | string | false | none | 更新日時 |
RequestInstantCrawlReq
{
"setting": {
"version": "1.0.0",
"crawl_file": {
"pdf": 0,
"ms_office": 0
},
"crawl_result_collection": {
"crawl_object": 1,
"url_list": 1,
"link_url_list": 0
},
"request_fingerprint": {
"keep_query": 1,
"keep_fragment": 0
},
"user_agent": "string",
"seed_urls": [
"string"
],
"allow_urls_patterns": [
"string"
],
"deny_urls_patterns": [
"string"
],
"documents_limit": 100,
"timezone": "string",
"language": "string",
"screenshot": {
"viewport_width": 1336,
"viewport_height": 768,
"render_all": false
},
"depth_limit": 5,
"authorizations": [
{
"type": "BASIC",
"url_pattern": "string",
"user": "string",
"password": "string"
}
],
"robots_txt": true,
"wait_type": 0,
"base_concurrent_requests": 1,
"download_delay": 0,
"execution_timeout": 0
}
}
RequestInstantCrawlReq
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
setting | InstantCrawlerSetting | true | none | * インスタントクローラーの設定モデル。 * すべての設定項目を指定する必要はない。 |
RequestInstantCrawlRes
{
"message": "string",
"status": "string",
"instant_crawl_request_id": 0
}
RequestInstantCrawlRes
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
message | string | false | none | API実行結果メッセージ (正常終了時はsuccess、障害時は原因内容を設定) |
status | string | false | none | API実行結果ステータス(OK/NG) |
instant_crawl_request_id | integer | false | none | クロール実行要求Id |
GetInstantCrawlerHistoriesRes
{
"message": "string",
"status": "string",
"crawl_histories": [
{
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0,
"crawl_url_list_path": "string"
}
]
}
GetInstantCrawlerHistoriesRes
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
message | string | false | none | 実行後メッセージ |
status | string | false | none | 実行結果 |
crawl_histories | [CrawlHistory] | false | none | クロール実行履歴群 |
GetInstantCrawlStatusesRes
{
"message": "string",
"crawl_status": {
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0
}
}
GetInstantCrawlStatusesRes
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
message | string | false | none | 実行後メッセージ |
crawl_status | CrawlStatus | false | none | * インスタントクローラーのクロール実行状態モデル。 * クロール実行状態1件分の結果を格納する。 |
CancelInstantCrawlRes
{
"message": "string",
"status": "string",
"crawl_status": {
"id": 0,
"instant_crawl_request_id": 0,
"crawl_execution_status_dtype_id": 0,
"crawl_execution_status_dtype_name": "string",
"is_cancel_request": true,
"start_datetime": "string",
"end_datetime": "string",
"crawled_url_count": 0,
"total_url_count": 0
}
}
CancelInstantCrawlRes
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
message | string | false | none | 実行後メッセージ |
status | string | false | none | 実行結果 |
crawl_status | CrawlStatus | false | none | * インスタントクローラーのクロール実行状態モデル。 * クロール実行状態1件分の結果を格納する。 |
INSTANT CRAWLER STATUS
- 以下、クロール実行状態種別 id/クロール実行状態種別名の一覧。
status_id | status_name | description1 | description2 |
---|---|---|---|
2010 | pending | 未稼働 | 本 API では利用しない |
2020 | running | 稼働 | 本 API では利用しない |
2030 | stopped | 停止 | 正常終了 |
2040 | troubled | 障害 | 異常終了 |
2050 | stopped_by_cancel | キャンセルによる停止 | キャンセル(クローラ成果物は作成されない) |
2060 | stopped_by_timeout | タイムアウトによる停止 | タイムアウトによる停止(クローラ成果物は作成されない) |
Download API v1
ダウンロード API の取得方法
本 API についても、他の API 同様にヘッダーに API キー(x-mf-apikey)の指定が必要。
以降で説明する URL にアクセスにすることで、一定時間アクセス可能な証明書付きの URL へリダイレクトされます。
リダイレクト時のステータスは 302。
アクセス可能時間は 30 秒です。
タイムアウト、キャンセル、エラーの場合は、クローラ成果物は作成されません。
例:CURL によるアクセス
※リダイレクトを有効にしてアクセス
curl --request GET \
--url https://dl.mf3.marsflag.com/instant_crawler/contracts/999/servicegroups/888/instant_crawl_requests/777/url_list.csv.gz \
--header 'x-mf-apikey: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' \
-location --output url_list.csv.gz
クロールリストダウンロード
INSTANT CRAWLER 履歴取得 API から取得(項目名:crawl_url_list_path)したパスからダウンロードが可能。
ダウンロードファイルは作成から一定時間経過後に削除される(PoC 時点では削除しないが、本番提供時は1週間程度を検討)。
ダウンロード URL のフォーマット
- https://dl.mf3.marsflag.com/instant_crawler/contracts/{contract_id}/servicegroups/{servicegroup_id}/instant_crawl_requests/{instant_crawl_request}/url_list.csv.gz
CSV ファイルフォーマット
- 以下、列順(No.)に記載。
No. | Name | Description1 | Description2 |
---|---|---|---|
1 | crawl_url | クロール URL | |
2 | last_url | 到達 URL | リダイレクトによって初回アクセス時の URL と違う時に設定 |
3 | is_crawl_ok | 成功/失敗 | true: 成功 false: 失敗 |
4 | crawl_datetime | クローラアクセス日時 | 例:2021-06-11T08:57:52.610269+0000 |
5 | http_status | HTTP ステータスコード | 例:200 |
6 | last_modified | Last-modified(Response ヘッダ) | 例:Wed, 09 Jun 2021 07:16:24 GMT |
7 | content_type | Content-Type(Response ヘッダ) | 例:text/htm |
8 | content_length | Content-Length(Response ヘッダ) | なければ最終的に取得できたコンテンツ容量を設定 |
クロール成果物ダウンロード
クロールリスト同様に INSTANT CRAWLER 履歴取得 API から取得(項目名:crawl_url_list_path)したパスからダウンロードが可能。
ダウンロードファイルは作成から一定時間経過後に削除される(PoC 時点では削除しないが、本番提供時は1週間程度を検討)。
クロール成果物として、クロールに成功したページの HTML(DOM データ)、スクリーンショットを1ファイル(tar.gz 形式)にまとめてダウンロードが可能。
スクリーンショットを含めたくない場合、ダウンロードファイルを作成しているクロール実行要求 API のパラメータにて Screenshot パラメータを指定しないでことで対応可能。
ダウンロード URL のフォーマット
- https://dl.mf3.marsflag.com/instant_crawler/contracts/{contract_id}/servicegroups/{servicegroup_id}/instant_crawl_requests/{instant_crawl_request}/crawl_objects.tar.gz
クロール成果物・HTML(DOM データ)の保存先フォルダの生成ルール
フォーマット
- {①https/http}/{②host}/{③path}-/{④query+fragment の URL エンコード}-/{プロパティ}
- ① プロトコル内(スキーマ)の「://」は削り、最後に「/」を付与
- ② と ③ の最後に「-/」を付与
- ④ の最後に「-/」を付与
- ※URL エンコードは JS の encodeURIComponent 関数を参考
例1 http://example.com/faq.html →https://image.mf3.marsflag.com/screenshot/http/example.com/faq.html-/-/cap_org.jpg
例2 http://example.com/faq →https://image.mf3.marsflag.com/screenshot/http/example.com/faq-/-/cap_org.jpg
例3(トレイリングスラッシュあり) http://example.com/faq/ →https://image.mf3.marsflag.com/screenshot/http/example.com/faq/-/-/cap_org.jpg
例4(トレイリングスラッシュあり) http://example.com/faq/?a=b#c=d →https://image.mf3.marsflag.com/screenshot/http/example.com/faq/-/{?a=b#c=dのURLエンコードした値}-/cap_org.jpg
例5 http://example.com/faq?a=b#c=d →https://image.mf3.marsflag.com/screenshot/http/example.com/faq-/{?a=b#c=dのURLエンコードした値}-/cap_org.jpg https://dl.mf3.marsflag.com/crawler/1_1_1_20210915133646770276/82d22e262926b622120eda5275d1fa68/crawl_objects.tar.gz
Errors
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is wrong. |
403 | Forbidden -- The kitten requested is hidden for administrators only. |
404 | Not Found -- The specified kitten could not be found. |
405 | Method Not Allowed -- You tried to access a kitten with an invalid method. |
406 | Not Acceptable -- You requested a format that isn't json. |
410 | Gone -- The kitten requested has been removed from our servers. |
418 | I'm a teapot. |
429 | Too Many Requests -- You're requesting too many kittens! Slow down! |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |