MCPcopy
hub / github.com/0xAX/linux-insides / main

Function main

scripts/get_all_links.py:42–68  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

40
41
42def main(path):
43
44 filenames = []
45 for (dirpath, dnames, fnames) in os.walk(path):
46 for fname in fnames:
47 if fname.endswith('.md'):
48 filenames.append(os.sep.join([dirpath, fname]))
49
50 urls = []
51
52 for filename in filenames:
53 fd = codecs.open(filename, mode="r", encoding="utf-8")
54 for line in fd.readlines():
55 refs = re.findall(r'(?<=<a href=")[^"]*', markdown.markdown(line))
56 for ref in refs:
57 if ref not in urls:
58 urls.append(ref)
59 fd.close()
60
61 for url in urls:
62 if not url.startswith("http"):
63 print("markdown file name: " + url)
64 continue
65 if check_live_url(url):
66 print(url)
67 else:
68 print(url, file=sys.stderr)
69
70
71if __name__ == '__main__':

Callers 1

get_all_links.pyFile · 0.85

Calls 1

check_live_urlFunction · 0.85

Tested by

no test coverage detected