Debian Codegraph @

examples/search/view_host_events.py

raw
1 """View host events."""
2
3 from censys.search import CensysHosts
4
5 h = CensysHosts()
6
7 # Fetch a list of events for the specified IP address.
8 events = h.view_host_events("1.1.1.1")
9 print(events)
10
11 # You can also pass in a date or datetime objects.
12 from datetime import date
13
14 events = h.view_host_events("1.1.1.1", per_page=1, start_time=date(2022, 1, 1), end_time=date(2022, 1, 31))
15 print(events)
16 # {
17 # 'ip': '1.1.1.1',
18 # 'events': [
19 # {
20 # 'timestamp': '2022-01-01T00:00:01.713Z',
21 # 'service_observed': {
22 # 'id': {'port': 80, 'service_name': 'HTTP', 'transport_protocol': 'TCP'},
23 # 'observed_at': '2021-12-31T23:59:39.910804158Z',
24 # 'perspective_id': 'PERSPECTIVE_NTT',
25 # 'changed_fields': [{'field_name': 'http.request.uri'}, {'field_name': 'http.response.headers.Cf-Ray.headers'}, {'field_name': 'http.response.headers.Location.headers'}, {'field_name': 'banner'}, {'field_name': 'banner_hashes'}]
26 # },
27 # '_event': 'service_observed'
28 # }
29 # ],
30 # 'links': {
31 # 'next': 'AS-RtkcKDRPshfT6ojz5ubSuyen_J_J2s9VLmJf9WCg7_jGt0KdU2JvoYW9QXof1Cskvm-b41QyRiR38kWADJuUA_w8rAA5ZNv9llYarhmPv22nIf88JFGGhH0h6dRZ7kDy5RfsiUxNFXeMQQXz0BWYrcQ=='
32 # }
33 # }