Request all Rapid Geography Descendants by cURL

Follow

Comments

1 comment

  • Avatar
    Ervin Chan

     

    Add python script as reference:

     

    # Mac version (If you have installed Homebrew, Ruby and Python, go to step 4 directly)
    # 1. Install Homebrew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    # 2. Install Ruby: brew install rbenv ruby-build
    # 3. Install Python 3: brew install python3
    # 4. Install Pipenv: pip install pipenv
    # 5. Install python requests package: pipenv install requests
    # Run python allgeo.py file.json

    import requests
    import json
    import hashlib
    import time
    import sys
    apiKey = 'your api key'
    secret = 'your secret'
    timestamp = str(int(time.time()));

    authHeaderValue = "EAN APIKey=" + apiKey + ",Signature=" + hashlib.sha512(apiKey+secret+timestamp).hexdigest() + ",timestamp=" + timestamp

    url = 'https://test.ean.com/2/regions/0/descendants?language=en-US&include=details'
    headers = {'accept': 'application/json', 'accept-encoding': 'gzip', 'customer-ip': '10.10.10.10', 'customer-session-id': '123', 'authorization': authHeaderValue}
    r = requests.get(url, headers=headers)
    fl = sys.argv[1]

    with open(fl, 'w') as outf:
    json.dump(r.content, outf, ensure_ascii=False)

Please sign in to leave a comment.