-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag_links_html.py
43 lines (31 loc) · 1.25 KB
/
tag_links_html.py
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
#Description: Takes a user-provided list of AO3 tags and creates an HTML file with clickable links so you can open the tags quickly.
#Requirements: Standard Python 3 library
#===================================#
#empty list to store tags
tagList = []
def make_tag_urls(tags):
#use the list to generate ao3 edit page urls
if tags == 'x':
print()
print('Bye! o(* ̄▽ ̄*)ブ')
exit()
else:
tagList = tags.split(', ')
print('Generating URLs...')
url = 'https://archiveofourown.org/tags/'
edit = '/edit'
tagUrls = list(map(lambda tag: url + tag + edit, tagList))
#add the html tags:
tag_a = list(map(lambda link: f'<a href="{link}">{link}</a><br>',tagUrls))
print(tag_a)
#output to an html file
with open('tags.html', 'w') as f:
f.writelines(tag_a)
print('Done! Check the folder for an HTML file!')
def main():
print('Oh no did you accidentally shovel fandom tags into NF? (╯O A O)╯︵┻━┻ \n This will create clickable links from the blurb confirmation at the top (or any other list of tags) so you can get them back easily! \n ')
while True:
tags = input('Paste your tags here, separated by COMMAS, or type x to exit: ')
make_tag_urls(tags)
print()
main()