Skip to content

Instantly share code, notes, and snippets.

@9b
Created August 26, 2017 03:51
Show Gist options
  • Save 9b/f5fe434bf9965d673963884b56d93d9a to your computer and use it in GitHub Desktop.
Save 9b/f5fe434bf9965d673963884b56d93d9a to your computer and use it in GitHub Desktop.
Simple tool to use WhatRuns API to get technologies used on a page. Doesn't submit the page if it's not in the database.
import ast
import datetime
import json
import sys
import requests
import urllib
from tabulate import tabulate
url = "https://www.whatruns.com/api/v1/get_site_apps"
data = {"data": {"hostname": sys.argv[1], "url": sys.argv[1],
"rawhostname": sys.argv[1]}}
data = urllib.urlencode({k: json.dumps(v) for k, v in data.iteritems()})
data = data.replace('+', '')
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
response = requests.post(url, data=data, headers=headers)
loaded = json.loads(response.content)
apps = ast.literal_eval(loaded['apps'])
nuance = apps.keys().pop()
entries = list()
for app_type, values in apps[nuance].iteritems():
for item in values:
dt = datetime.datetime.fromtimestamp((item['detectedTime']/1000))
ldt = datetime.datetime.fromtimestamp((item['latestDetectedTime']/1000))
entries.append({'Type': app_type, 'Name': item['name'],
'Detected': dt, 'Last_Detected': ldt})
print tabulate(entries, headers='keys')
Copy link

ghost commented Feb 10, 2022

Thanks

@KaKi87
Copy link

KaKi87 commented Feb 25, 2022

Hello,
Would you know how to port this to JS ?
I tried :

await axios.post(
    'https://www.whatruns.com/api/v1/get_site_apps',
    new URLSearchParams({
        'hostname': url,
        'url': url,
        'rawhostname': url
    })
);

And got :

{ exception: 'SyntaxError: Unexpected token u in JSON at position 0' }

as response body.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment