Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Merton committed Aug 10, 2018
1 parent af584f3 commit 7cecd03
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,40 @@ To install the required packages use `pip`:
`pip install -r requirements.txt`

## Usage
### Command Line & Server side
To run the script, ensure you have python (min <2.7) installed and run:
`python linker.py`

Copy the contents of the `config.ini.example` file into `config.ini` in the same directory.

Modify your config file with the details for your site.

*GENERAL*
Config option | Description
------------- | -----------
UseLocalFile | yes(default)/no
LocalSitemapFile | File path + name relative to this directory
DownloadSitemap | yes/no(default)
RemoteSitemapUrl | The url of the sitemap hosted on your website
OutputToFile | yes(default)/no
OutputFileName | Name of the file that the results will store. Can be placed elsewhere using relative path

*GENERAL*
Config option | Description
------------- | -----------
SiteName | The name of your site, this is for display only and gets used in the output for easier identification
EmailOutput | yes/no(default)
AdminEmailAddress | The address of that emails will be sent from
AdminEmailPassword | The password of the Admins email account *PLAIN TEXT!*
RecipientEmailAddress | The recipient's email where the output gets sent to

### Graphical interface
Enter the linker directory, and run:
`python main.py`

From here you can enter or browse for the filename of the XML sitemap, and click enter.

#### HTTP Auth
If your site has a username and password,

### Command Line
To run the script, ensure you have python (min <2.7) installed and run:
`python linker.py`

You will be asked if you want to use a sitemap hosted on your website, these are often found at `/sitemap.xml`. If you would rather use a local xml file, leave it blank and you will be prompted for the filepath of the sitemap.
If your site has http authentication, then you will be asked to enter the username and password for the site. These details are not stored.

The script will carry out the test on every url, and then output a report of all the broken links found.
2 changes: 2 additions & 0 deletions config.ini.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
;COPY THE CONTENTS OF THIS EXAMPLE INTO A "config.ini" FILE

[OPTIONS]
;Use exisiting sitemap on system, include xml extension
UseLocalFile=yes
Expand Down
6 changes: 3 additions & 3 deletions linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def run():
subject = "ALERT: {} Broken Links detected for {}".format(count_broken_links, email_conf['SiteName'])
message = "There were {} broken links found! \n".format(count_broken_links)

# Formats the links into a human readable format, writes to file and generates message
# Formats the links into a human readable format
for url, error, location in broken_links:
broken_link = """
===== BROKEN LINK ============
Expand All @@ -185,12 +185,12 @@ def run():
print( "Error: ", str(error), " => URL: ", str(url), "Location: ", str(location))
message += broken_link

# Write to file
# Writes to file
if gen_conf['OutputToFile'] == 'yes':
with open(gen_conf['OutputFileName'], 'w') as file:
file.write(message)

# Email output
# Emails the output to address specified in config.ini
if email_conf['EmailOutput'] == 'yes':
send_mail(email_conf, subject, message)

Expand Down

0 comments on commit 7cecd03

Please sign in to comment.