@@ -66,8 +66,8 @@ def get_final_url(url):
6666 response_json = submit_response .json ()
6767 error_message = response_json .get ("message" , "" )
6868 if (
69- "DNS Error" in error_message
70- or "could not resolve domain" in error_message .lower ()
69+ "DNS Error" in error_message
70+ or "could not resolve domain" in error_message .lower ()
7171 ):
7272 log (f"Domain cannot be resolved. Marking as INACTIVE: { url } " )
7373 return url # Return original URL, which will be marked as INACTIVE
@@ -145,7 +145,7 @@ def get_final_url(url):
145145def process_account (account , details , request_timestamps ):
146146 """Process a single account and update its URL details."""
147147 surface_url = details .get ("SURFACE_URL" , "" )
148- if not surface_url :
148+ if not surface_url or surface_url . lower () in [ "no url sent" , "no url detected" ] :
149149 return False , request_timestamps
150150
151151 if urlparse (surface_url ).netloc in EXCLUDED_DOMAINS :
@@ -247,7 +247,9 @@ def main():
247247 print (f"There are { total_accounts } accounts in total." )
248248 while True :
249249 try :
250- start_number = int (input (f"Enter starting account number (1-{ total_accounts } ): " ))
250+ start_number = int (
251+ input (f"Enter starting account number (1-{ total_accounts } ): " )
252+ )
251253 if 1 <= start_number <= total_accounts :
252254 start_index = start_number - 1
253255 break
@@ -262,19 +264,25 @@ def main():
262264 total_excluded = 0
263265 total_active = 0
264266 total_inactive = 0
267+ total_skipped_no_url = 0 # New counter for skipped cases
265268 request_timestamps = [] # Track when requests were made for rate limiting
266269
267270 # Process each account entry with proper rate limiting
268271 for i , (account , details ) in enumerate (items [start_index :], start = start_index ):
269272 surface_url = details .get ("SURFACE_URL" , "" )
270- if not surface_url :
273+
274+ # Skip if no URL or contains "No URL Sent" or "No URL Detected"
275+ if not surface_url or surface_url .lower () in ["no url sent" , "no url detected" ]:
276+ total_skipped_no_url += 1
271277 continue
272278
273279 if urlparse (surface_url ).netloc in EXCLUDED_DOMAINS :
274280 total_excluded += 1
275281 continue
276282
277- is_active , request_timestamps = process_account (account , details , request_timestamps )
283+ is_active , request_timestamps = process_account (
284+ account , details , request_timestamps
285+ )
278286
279287 if is_active :
280288 total_active += 1
@@ -288,7 +296,13 @@ def main():
288296 log ("Finished processing. All results have been saved to the JSON file." )
289297 log ("Final Statistics:" )
290298 excluded_plural = "s" if total_excluded != 1 else ""
291- log (f"- Total accounts skipped: { total_excluded } account{ excluded_plural } " )
299+ log (
300+ f"- Total accounts skipped (excluded domains): { total_excluded } account{ excluded_plural } "
301+ )
302+ skipped_url_plural = "s" if total_skipped_no_url != 1 else ""
303+ log (
304+ f"- Total accounts skipped (no URL): { total_skipped_no_url } account{ skipped_url_plural } "
305+ )
292306 active_plural = "s" if total_active != 1 else ""
293307 log (f"- URLs flagged as ACTIVE: { total_active } account{ active_plural } " )
294308 inactive_plural = "s" if total_inactive != 1 else ""
0 commit comments