Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.0 kB
5
Indexable
Never
#!/usr/bin/env python3

import argparse
import requests
from bs4 import BeautifulSoup
argparser = argparse.ArgumentParser(description='build an ublock list from a current codex ignore list') 
argparser.add_argument('accountid', metavar='id', type=int, nargs=1, help='user id on the codex')
argparser.add_argument('cookie', metavar='ck', type=str, nargs=1, help='your user account cookie data, look for "cdx_session=" in your browser')
args = argparser.parse_args()

accountid = str(args.accountid[0])
usersession = args.cookie[0]
URL = "https://rpgcodex.net/ignore.php?user=" + accountid
cookies = dict(cdx_session=args.cookie[0])
page = requests.get(URL, cookies=cookies)
s = BeautifulSoup(page.text, features='lxml')
tables = s.findChildren('table')
tp = tables[4]
fagtables = tp.find_all('td',{'align':'left'})
f = []
IL = ''
for fag in fagtables:
    f.append(fag.text)
for fag in f:
    IL += ('rpgcodex.net##article[data-author=\"' + fag + '\"]' + '\n')
 
il_file = open("ignorelistublock.txt", "w")
il_file.write(IL)
il_file.close()