Download the latest whois information.
(logger, whois_collection, remote_whois_collection)
| 115 | |
| 116 | |
| 117 | def download_whois_data(logger, whois_collection, remote_whois_collection): |
| 118 | """ |
| 119 | Download the latest whois information. |
| 120 | """ |
| 121 | logger.info("Beginning Whois download") |
| 122 | whois_results = remote_whois_collection.find({}, {"_id": 0}).batch_size(50) |
| 123 | |
| 124 | for result in whois_results: |
| 125 | whois_collection.replace_one({"zone": result["zone"]}, result, upsert=True) |
| 126 | |
| 127 | # Establish a date four months back |
| 128 | scrub_date = datetime.now() - timedelta(days=120, hours=9) |
| 129 | |
| 130 | # Remove data from four months back |
| 131 | whois_collection.delete_many({"updated": {"$lte": scrub_date}}) |
| 132 | |
| 133 | |
| 134 | def check_zones(domain, zones): |