서버정보

URL
api.hashscraper.com/api/dataset
Port
80
Status
ACTIVE

Parameter

Key Required Description
api_key 필수 해시스크래퍼 API키
schedule_id 필수 최근 수집된 데이터 요청
schedule_result_id 특정 스케줄리절트의 데이터 요청
updated_at 특정 시점 이후 업데이트된 데이터만 전달 ex) 2019-09-10 01:28:52

Ruby 샘플코드

begin
  api_key = '[해시스크래퍼 API키]'
  schedule_id = '[스케줄 ID]'

  host = 'api.hashscraper.com'
  port = '80'
  path = "/api/dataset?schedule_id=#{schedule_id}&api_key=#{api_key}"

  request = Net::HTTP::Get.new(
		path,
		initheader = { 'Content-Type' => 'application/json; version=2' }
	)
  response = Net::HTTP.new(host, port).start {|http| http.request(request)}

  puts response.body
  puts response.body.as_json

  json = JSON.parse(response.body)
  puts("response.body: #{response.body}, count: #{json['count'].to_i}")

  puts json
rescue => e
  puts e
end

            

Python 샘플코드

import requests
api_key = '[해시스크래퍼 API키]'
schedule_id = '[스케줄 ID]'

host = 'api.hashscraper.com'
port = '80'
path = "/api/dataset?"
url = 'http://' + host + ':' + port + path
params = {'api_key' : api_key, 'schedule_id' : schedule_id}
headers = {'Content-Type' : 'application/json; version=2'}
res = requests.get(url, verify=False, params=params, headers=headers)
print(res.json())

            

NodeJS 샘플코드

let api_key = '[해시스크래퍼 API키]';

let schedule_id = '[스케줄 ID]';

var http = require('http');

var opts = {
    host: 'api.hashscraper.com',
    port: 80,
    method: 'POST',
    path: '/api/dataset?schedule_id=' + schedule_id + '&api_key=' + api_key,
    headers: { 'Content-Type': 'application/json; version=2'}
};


var resData = '';

var req = http.request(opts, function(res){
    //응답처리
    res.on('data', function(chunk){
        resData += chunk;
    });

    res.on('end', function(){
        console.log(resData);
    });
});

opts.headers['Content-Type'] = 'application/json; version=2';
req.data = '';
opts.headers['Content-Length'] = req.data.length;

req.on('error', function(err){
    console.log("오류발생:"+ err.message);
})

//요청전송
req.write(req.data);
req.end();

            

PHP 샘플코드

<php
class Log {
    public static function debug($str) {
        print "DEBUG: " . $str . "\n";
    }
    public static function info($str) {
        print "INFO: " . $str . "\n";
    }
    public static function error($str) {
        print "ERROR: " . $str . "\n";
    }
}

function Curl($url, $post_data, &$http_status, &$header = null) {
    Log::debug("Curl $url JsonData=" . $post_data);
    $ch=curl_init();

    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);

    // post_data
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    if (!is_null($header)) {
        curl_setopt($ch, CURLOPT_HEADER, true);
    }
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json; version=2'));
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    $response = curl_exec($ch);
    Log::debug('Curl exec=' . $url);

    $body = null;
    // error
    if (!$response) {
        $body = curl_error($ch);
        // HostNotFound, No route to Host, etc  Network related error
        $http_status = -1;
        Log::error("CURL Error: = " . $body);
    } else {
       //parsing http status code
        $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if (!is_null($header)) {
            $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
            $header = substr($response, 0, $header_size);
            $body = substr($response, $header_size);
        } else {
            $body = $response;
        }
    }
    curl_close($ch);
    return $body;
}

$url = "http://api.hashscraper.com/api/dataset?schedule_id=[스케줄 ID]&api_key=[해시스크래퍼 API키]";
$json = "";
$ret = Curl($url, $json, $http_status);
var_dump($ret);

$myfile = fopen('api_result.json', 'w');
fwrite($myfile, $ret);
fclose($myfile);
?>

            

응답 JSON

{
  "result": "success",
  "version": "v2",
  "data": {
    "id": 47977,
    "user_id": 38,
    "schedule_id": 75,
    "success": true,
    "total": 1,
    "processed": 576,
    "fail": 0,
    "date": "2019-09-10",
    "hour": 1,
    "auto_start_count": 0,
    "created_at": "2019-09-10T01:00:23.000+09:00",
    "updated_at": "2019-09-10T01:28:51.000+09:00",
    "sum_point": 0,
    "schedule_type": null,
    "hidden": false,
    "results": [
      {
        "id": 3705561,
        "created_at": "2019-09-10T01:17:22.000+09:00",
        "updated_at": "2019-09-10T01:17:22.000+09:00",
        "사이트": "coupang",
        "URL": "https://trip.coupang.com/tp/products/100000019082",
        "제목": "뮤지컬 김종욱찾기 ★좋은자리★ #대학로#혜화#데이트",
        "대표이미지": "http://image15.coupangcdn.com/image/resized_image/thumbnails/remote/1180x2360q60crop1180x630/image/travelSeller/common/A00193844/a1b257d2-4a8c-4cd5-941d-2b7a7228d0b1.png",
        "장소": "{\"address\":\"서울특별시 종로구 대학로12길 73 컬처스페이스 엔유\",\"place\":null}",
        "출연자": "null",
        "가격": "[{\"name\":null,\"price\":12900,\"sale_price\":null,\"sale_price_desc\":null}]",
        "장르": "뮤지컬/콘서트",
        "시작일": "2019-09-10",
        "종료일": null,
        "오픈런": null,
        "평점": "5.0",
        "상세이미지": "{\"detail_img_list\":[\"http://image15.coupangcdn.com/image/travelSeller/common/A00193844/02477873-732f-49f6-bf51-111eeca842c8.jpg\",\"http://image15.coupangcdn.com/image/travelSeller/common/A00193844/be2ef8e1-c4d9-44b4-b038-c7fc4b23dd8a.jpg\",\"http://image15.coupangcdn.com/image/travelSeller/common/A00193844/27f5298f-f19e-4109-ab42-95194774d4ec.jpg\",\"http://image15.coupangcdn.com/image/travelSeller/common/A00193844/860c9280-3aa2-4b6e-9cc3-3cb6e4c7d05d.jpg\"],\"youtube_list\":null}"
      }
    ]
  }
}