Skip to content

Basic Host Info

Jeremy Barlow edited this page Mar 28, 2018 · 4 revisions

This sample invokes and displays information about a specific website by invoking the URLVoid API service via DXL.

See Host Info Documentation for more details.

The majority of the sample code is shown below:

Sample Code

# Create the client
with DxlClient(config) as client:

    # Connect to the fabric
    client.connect()

    logger.info("Connected to DXL fabric.")

    # Invoke 'host info' method
    request_topic = "/opendxl-urlvoid/service/urlvapi/host/info"

    req = Request(request_topic)
    MessageUtils.dict_to_json_payload(req, {"host": "027.ru"})

    res = client.sync_request(req, timeout=60)
    if res.message_type != Message.MESSAGE_TYPE_ERROR:
        payload = MessageUtils.decode_payload(res)
        xml = xml.dom.minidom.parseString(payload)
        print("Response for URLVoid host info:")
        print(xml.toprettyxml(
            indent='    ', newl='', encoding="UTF-8").decode("UTF-8"))
    else:
        print("Error invoking service with topic '{0}': {1} ({2})".format(
            request_topic, res.error_message, res.error_code))

After connecting to the DXL fabric, a request message is created with a topic that targets the "host info" method of the URLVoid DXL service.

The next step is to set the payload of the request message. The contents of the payload include the host to report on).

Output

The output should appear similar to the following:

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <details>
         <host>027.ru</host>
         <updated>1499898632</updated>
         <http_response_code>0</http_response_code>
         <domain_age>1134018000</domain_age>
         <google_page_rank>0</google_page_rank>
         <alexa_rank>0</alexa_rank>
         <connect_time>0</connect_time>
         <header_size>0</header_size>
         <download_size>0</download_size>
         <speed_download>0</speed_download>
         <external_url_redirect/>
         <ip>
            <addr>185.53.177.31</addr>
            <hostname/>
            <asn>61969</asn>
            <asname>Team Internet AG</asname>
            <country_code>DE</country_code>
            <country_name>Germany</country_name>
            <region_name/>
            <city_name/>
            <continent_code>EU</continent_code>
            <continent_name>Europe</continent_name>
            <latitude>51.2993</latitude>
            <longitude>9.491</longitude>
         </ip>
    </details>
    <detections>
        <engines>
             <engine>MyWOT</engine>
             <engine>SCUMWARE</engine>
             <engine>Avira</engine>
        </engines>
         <count>3</count>
    </detections>
    <page_load>0.01</page_load>
</response>

The report associated with the specified host is displayed.

Home

URLVoid DXL Python Service

Documentation

Service Methods

Examples

Clone this wiki locally