Basic Host Rescan Example ========================= This sample updates the report for a specific website (triggers a rescan) by invoking the URLVoid API service via DXL. For more information see: http://api.urlvoid.com/dashboard/#usage Prerequisites ************* * The samples configuration step has been completed (see :doc:`sampleconfig`) * The URLVoid API DXL service is running (see :doc:`running`) Running ******* To run this sample execute the ``sample/basic/basic_host_rescan.py`` script as follows: .. parsed-literal:: python sample/basic/basic_host_rescan.py The output should appear similar to the following: .. code-block:: xml Response for URLVoid host rescan:
027.ru 1499901690 0 1134018000 0 0 0 0 0 0 185.53.177.31 61969 Team Internet AG DE Germany EU Europe 51.2993 9.491
MyWOT SCUMWARE Avira 3 OK 5.06
The received results are displayed. Details ******* The majority of the sample code is shown below: .. code-block:: python # Create the client with DxlClient(config) as client: # Connect to the fabric client.connect() logger.info("Connected to DXL fabric.") # Invoke 'host rescan' method request_topic = "/opendxl-urlvoid/service/urlvapi/host/rescan" 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 rescan:") 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 rescan" method of the URLVoid API DXL service. The next step is to set the `payload` of the request message. The contents of the payload include the `host` to rescan. The final step is to perform a `synchronous request` via the DXL fabric. If the `response message` is not an error its contents are displayed.