Skip to content

Commit

Permalink
fixed export .txt bug and now we make .json
Browse files Browse the repository at this point in the history
  • Loading branch information
ImanMontajabi committed Apr 9, 2023
1 parent b9cc97b commit ff2f028
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions CloudflareDNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def list(self):
i_num += 1
self.finished.emit()
self.finished.emit()
# export list
def export_list(self):
# export json
def export_json(self):
with open('user_id.json', 'r') as json_file:
user_data = json.load(json_file)

Expand All @@ -88,7 +88,11 @@ def export_list(self):
}
dns_records = []
page_num = 1
export_list = []
export_json = {}
export_json["workingIPs"] = []
#make json files with IPs and <<< same Dataed >>> # TODO change the Dates
export_json["startDate"] = "2023-04-04T10:41:35.5737055-07:00"
export_json["endDate"] = "2023-04-04T10:41:35.5737056-07:05"
while True: # loop over all pages
params = {'page': page_num, 'per_page': 100} # update pagination params
response = requests.request('GET', url, headers=headers, params=params)
Expand All @@ -105,11 +109,15 @@ def export_list(self):
this_dns_record = subdomain.replace(f".{this_domain}", "")
if this_dns_record == dns_record_name:
content = record['content']
export_list.append(f"{number} - {content}")
#add dns record working ips to json file
export_json["workingIPs"].append({"delay": number, "ip": content})
self.progress.emit((i_num + 1, subdomain, content,"✓"))
i_num += 1
with open(f"{dns_record_name}.{domain}.txt", "w") as f:
f.write("\n".join(export_list))
export_json["totalFoundWorkingIPs"] = i_num
export_json["totalFoundWorkingIPsCurrentRange"] = i_num

with open(f"{dns_record_name}.{domain}.json", "w") as f:
json.dump(export_json, f)
f.close()
self.finished.emit()
self.finished.emit()
Expand Down Expand Up @@ -209,7 +217,7 @@ def bestip():
if ipn >= max_ips:
break
self.finished.emit()
# ===================================================================================
# delete all ips of sumdomain
def delete(self):
with open('user_id.json', 'r') as json_file:
user_data = json.load(json_file)
Expand Down Expand Up @@ -453,7 +461,7 @@ def exportlist_clicked(self):
self.otext.clear()
self.worker.moveToThread(self.thread)
self.worker.progress.connect(self.update_text)
self.thread.started.connect(self.worker.export_list)
self.thread.started.connect(self.worker.export_json)
self.worker.finished.connect(self.thread.quit)
self.worker.finished.connect(self.worker.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
Expand Down

0 comments on commit ff2f028

Please sign in to comment.