This efficient Link Validator is written in Python using the Python modules Pandas and Requests. Using the streaming option of the requests module helps to complete the validation without fully downloading very large files.
The URLs are read from an Excel file (Links worksheet) using pandas.read_excel
and the rows are processed using the pandas DataFrame.apply
subroutine. The Link Validation status is written to another Excel file using pandas.ExcelWriter
.
Usage
pip3 install pandas
pip3 install requests
pip3 install xlrd
pip3 install openpyxl
# Read URLs from Excel file
df = pandas.read_excel("D:\\Selenium\\Link_Validator.xlsx",sheet_name="Links")
...
# Write status as Excel file
with pandas.ExcelWriter("D:\\Selenium\\Link_Status.xlsx") as writer:
df.to_excel(writer, sheet_name="Link Status", index=False)
C:\Users\Arun>D:
D:\>cd Selenium
D:\Selenium>python Link_Validator.py
Status: 200 Time: 0.6112735271453857
Final URL: http://example.com/
Status: 200 Time: 0.5624599456787109
Final URL: http://example.org/
D:\Selenium>
Link_Validator.py