다중 수집

URL
api.hashscraper.com/api/collect_multiple
요청방식
POST
Port
80
Status
ACTIVE

Header

Key Required Value
Content-Type 필수 application/json; version=2

Parameter

Key Required Description
api_key 필수 해시스크래퍼 API 키 (API키는 오른쪽 위 프로필을 누르신후 내 정보에 가시면 얻을수 있습니다.)
schedules[schedule_id] 필수 Schedule Id
schedules[param1] param1
schedules[param2] param2
schedules[param3] param3
schedules[param4] param4
schedules[param5] param5

참고 사항

get_param_info API로 어떤 파라미터가 필요한지 확인 후 입력해주세요.

샘플코드

  • cURL
  • Ruby
  • Python
  • NodeJS
  • PHP
  • Java
curl -X POST \
  --header "Content-Type: application/json; version=2" \
  --data '{
    "api_key": "YOUR_API_KEY",
    "schedules": [
      {
        "schedule_id": "YOUR_SCHEDULE_ID_1",
        "param1": "1",
        "param2": "2",
        "param3": "3",
        "param4": "4",
        "param5": "5"
      },
      {
        "schedule_id": "YOUR_SCHEDULE_ID_2",
        "param1": "1",
        "param2": "2",
        "param3": "3",
        "param4": "4",
        "param5": "5"
      }
    ]
  }' \
  'api.hashscraper.com/api/collect_multiple'

              
begin
  api_key = 'YOUR_API_KEY'

  host = 'api.hashscraper.com'
  port = '80'
  path = "/api/collect_multiple"

  request = Net::HTTP::Post.new(path)

  schedule_id_1 = 'YOUR_SCHEDULE_ID_1'
  schedule_id_2 = 'YOUR_SCHEDULE_ID_2'

  request['Content-Type'] = 'application/json; version=2'
  request.body = {
    api_key: api_key,
    schedules: [
    {
      schedule_id: schedule_id_1,
      param1: '1',
      param2: '2',
      param3: '3',
      param4: '4',
      param5: '5'
    },
    {
      schedule_id: schedule_id_2,
      param1: '1',
      param2: '2',
      param3: '3',
      param4: '4',
      param5: '5'
    }
  ]
  }.to_json

  response = Net::HTTP.start(host, port) do |http|
    http.request(request)
  end

  puts response.body
rescue => e
  puts e
end

            
import requests
import json

api_key = 'YOUR_API_KEY'

url = 'http://api.hashscraper.com/api/collect_multiple'

headers = {
  'Content-Type': 'application/json; version=2'
}

schedule_id_1 = 'YOUR_SCHEDULE_ID_1'
schedule_id_2 = 'YOUR_SCHEDULE_ID_2'

data = {
  'api_key': api_key,
  'schedules': [
    {
      'schedule_id': schedule_id_1,
      'param1': '1',
      'param2': '2',
      'param3': '3',
      'param4': '4',
      'param5': '5'
    },
    {
      'schedule_id': schedule_id_2,
      'param1': '1',
      'param2': '2',
      'param3': '3',
      'param4': '4',
      'param5': '5'
    }
  ]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.text)

            
const api_key = 'YOUR_API_KEY';

const host = "api.hashscraper.com";
const port = 80;
const path = "/api/collect_multiple";

const schedule_id_1 = 'YOUR_SCHEDULE_ID_1';
const schedule_id_2 = 'YOUR_SCHEDULE_ID_2';

const requestData = {
  api_key: api_key,
  schedules: [
    {
      schedule_id: schedule_id_1,
      param1: "1",
      param2: "2",
      param3: "3",
      param4: "4",
      param5: "5",
    },
    {
      schedule_id: schedule_id_2,
      param1: "1",
      param2: "2",
      param3: "3",
      param4: "4",
      param5: "5",
    },
  ],
};

const requestOptions = {
  method: "POST",
  headers: {
    "Content-Type": "application/json; version=2",
  },
  body: JSON.stringify(requestData),
};

async function makeRequest() {
  try {
    const response = await fetch(
      `http://${host}:${port}${path}`,
      requestOptions
    );
    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error(error.message);
  }
}

makeRequest();

            
<?php

$api_key = 'YOUR_API_KEY';

$host = 'api.hashscraper.com';
$port = '80';
$path = '/api/collect_multiple';

$url = 'http://' . $host . ':' . $port . $path;

$user_agent = "MyApp/1.0"; // 원하는 User-Agent 값을 여기에 설정하세요

$headers = array(
    'Content-Type: application/json; version=2',
    "User-Agent: $user_agent"
);

$schedule_id_1 = 'YOUR_SCHEDULE_ID_1';
$schedule_id_2 = 'YOUR_SCHEDULE_ID_2';

$data = array(
    'api_key' => $api_key,
    'schedules' => array(
        array(
            'schedule_id' => $schedule_id_1,
            'param1' => '1',
            'param2' => '2',
            'param3' => '3',
            'param4' => '4',
            'param5' => '5',
        ),
        array(
            'schedule_id' => $schedule_id_2,
            'param1' => '1',
            'param2' => '2',
            'param3' => '3',
            'param4' => '4',
            'param5' => '5',
        ),
    ),
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
if ($response === false) {
    die('Error: ' . curl_error($ch));
}

curl_close($ch);

echo $response;

            
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {

    public static void main(String[] args) {
        String apiKey = 'YOUR_API_KEY';

        String host = "api.hashscraper.com";
        String port = "80";
        String path = "/api/collect_multiple";

        String scheduleId1 = 'YOUR_SCHEDULE_ID_1';
        String scheduleId2 = 'YOUR_SCHEDULE_ID_2';

        try {
            URL url = new URL("http://" + host + ":" + port + path);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json; version=2");
            connection.setDoOutput(true);

            JSONObject schedule1 = new JSONObject();
            schedule1.put("schedule_id", scheduleId1);
            schedule1.put("param1", "1");
            schedule1.put("param2", "2");
            schedule1.put("param3", "3");
            schedule1.put("param4", "4");
            schedule1.put("param5", "5");

            JSONObject schedule2 = new JSONObject();
            schedule2.put("schedule_id", scheduleId2);
            schedule2.put("param1", "1");
            schedule2.put("param2", "2");
            schedule2.put("param3", "3");
            schedule2.put("param4", "4");
            schedule2.put("param5", "5");

            JSONArray schedules = new JSONArray();
            schedules.put(schedule1);
            schedules.put(schedule2);

            JSONObject jsonRequest = new JSONObject();
            jsonRequest.put("api_key", apiKey);
            jsonRequest.put("schedules", schedules);

            OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
            out.write(jsonRequest.toString());
            out.flush();
            out.close();

            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }
                in.close();
            }

            System.out.println(response.toString());

        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

            

API 응답 샘플

{
  "result": "success",
  "version": "v2",
  "collect_info": [
    {
      "schedule_result_id": 13229288,
      "schedule_id": "사람인 채용공고 수집_1697441449957",
      "param_info": {
        "param1(검색할 키워드)": "개발자",
        "param2(최대 수집 개수)": "10"
      }
    },
    {
      "schedule_result_id": 13229289,
      "schedule_id": "잡코리아 채용정보 수집_1697187514090",
      "param_info": {
        "param1(검색키워드)": "개발자",
        "param2(최대수집개수)": "10"
      }
    }
  ]
}