#!/usr/bin/python

import re
import sys

from bs4 import BeautifulSoup
from urllib.request import urlopen

SCP_SERIES_REGEX = re.compile(r'/scp-[0-9]{3,4}')

def count_slots(url):
    with urlopen(url) as response:
        data = response.read()

    empty_slots = 0
    total_slots = 0
    scps = set()

    soup = BeautifulSoup(data, 'html.parser')
    for link in soup.select('.series a'):
        href = link.get('href')
        if href is None or SCP_SERIES_REGEX.match(href) is None:
            continue

        if href in scps:
            continue

        scps.add(href)
        total_slots += 1
        if link.get('class') == ['newpage']:
            empty_slots += 1

    return empty_slots, total_slots

if __name__ == '__main__':
    if len(sys.argv) > 1:
        series = int(sys.argv[1])
    else:
        series = 5

    url = f'http://www.scp-wiki.net/scp-series-{series}'
    print(f'Counting slots in {url}...')
    empty, total = count_slots(url)
    print(f'{empty} / {total} slots empty ({empty/total*100:.2f}%)')

@@ -712,16 +712,176 @@
 _slots%0A%0A
+def get_series_url(number):%0A    if number == 1:%0A        return 'http://www.scp-wiki.net/scp-series'%0A%0A    return f'http://www.scp-wiki.net/scp-series-%7Bseries%7D'%0A%0A
 if __nam
@@ -1003,54 +1003,30 @@
 l = 
-f'http://www.scp-wiki.net/scp-
+get_
 series
--%7B
+_url(
 series
-%7D'
+)
 %0A   

Add support for Series I.