I wanted to show what can be done with RPA inside of Python. I have written a small script that takes in a list of domains and checks them against SSL Labs.
Code can be found in my GitHub
There is an API for this website, but I wanted to use RPA to show it off. It’s not overly quick. And I’m certain that the API would be significantly faster, but it is something working with RPA to demonstrate what can be accomplished when no other automation is possible.
Script Info
This is a quite straightforward script that will check multiple domains one after another. There are a number of caveats to SSL Labs on the web interface.
- The scanning. RPA doesn’t care if a domain is being scanned. It is looking for the summary with the grade in it. If that is not presented by default it will move on to the next domain. I have used a while loop that is looking for the summary and will not continue until it does.
- If there are multiple DNS entries then SSL Labs will scan each (one by one) and present a table. This table doesn’t have the summary that my RPA script is looking for.
I have the script click on the IP in the first row and pull the summary from that. This is usually only seen from larger websites.
Now that they are out of the way we can scan some domains. I picked some random domains that had been scanned earlier in the day, and some larger ones that I knew would trigger the table (mentioned in point 2).
Script Version 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import rpa as r import os import time startTime = time.time() basedir = os.path.abspath(os.path.dirname(__file__)) r.init(True, True) # Change wait timout default to 2 seconds r.timeout(2) # Check a list of domains domains = ["google.com", "login.saipem.com", "techviewleo.com", "ask.com", "enable.adaptivecloud.com", "ulanov.store"] resultlist = [] for domain in domains: domain_ent = domain + '[enter]' r.url('https://www.ssllabs.com/ssltest/') r.wait(0.5) r.type('//*[@name="d"]', domain_ent) print(f"Checking: {domain}") # Look for summary summary = r.read('//*[@id="main"]/div[5]/div[1]/div[1]') multiTable = False while not summary: # Check for refresh for ongoing scan # Check for a multiTable with elif if r.read('//*[@id="refreshUrl"]'): print("Scanning in progress") elif r.read('//*[@id="multiTable"]'): multiTable = True print("Multi Table Found") break print("Checking for summary again, waiting 10 seconds") r.wait(10) summary = r.read('//*[@id="main"]/div[5]/div[1]/div[1]') if multiTable: r.click('//*[@id="multiTable"]/tbody/tr[3]/td[2]/span[1]/b/a') # Do something to get the summary result = r.read('//*[@id="rating"]') fixed = " ".join(result.split()) resultdict = {"Domain":domain, "Result":fixed } resultlist.append(resultdict) print(fixed) print("Moving on to next domain\n\n") r.close() for domain in resultlist: print(domain) executionTime = (time.time() - startTime) print('Execution time in seconds: ' + str(executionTime)) |
Output
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
Checking: google.com [RPA][ERROR] - cannot find //*[@id="main"]/div[5]/div[1]/div[1] [RPA][ERROR] - cannot find //*[@id="refreshUrl"] Multi Table Found Overall Rating B Moving on to next domain Checking: login.saipem.com Overall Rating A+ Moving on to next domain Checking: techviewleo.com [RPA][ERROR] - cannot find //*[@id="main"]/div[5]/div[1]/div[1] [RPA][ERROR] - cannot find //*[@id="refreshUrl"] Multi Table Found Overall Rating B Moving on to next domain Checking: ask.com Overall Rating A+ Moving on to next domain Checking: enable.adaptivecloud.com Overall Rating A+ Moving on to next domain Checking: ulanov.store Overall Rating A+ Moving on to next domain {'Domain': 'google.com', 'Result': 'Overall Rating B'} {'Domain': 'login.saipem.com', 'Result': 'Overall Rating A+'} {'Domain': 'techviewleo.com', 'Result': 'Overall Rating B'} {'Domain': 'ask.com', 'Result': 'Overall Rating A+'} {'Domain': 'enable.adaptivecloud.com', 'Result': 'Overall Rating A+'} {'Domain': 'ulanov.store', 'Result': 'Overall Rating A+'} Execution time in seconds: 48.31660985946655 |