From 5aa70ab22de1296d4ff6cd38a8aff2cb26d5cc20 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Tue, 6 Aug 2024 10:12:56 +0200 Subject: [PATCH] Finally add csv output to scraper --- scrape_docs.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scrape_docs.py b/scrape_docs.py index a5fa836..e3fde25 100755 --- a/scrape_docs.py +++ b/scrape_docs.py @@ -35,15 +35,20 @@ def scrape(output, url): link = e['href'] if output == 'default': print(f'{e.text} {link}') - if output == 'rst': + if output in ['rst', 'csv']: parts = chapter.split('admin_api') fulllink = f'{parts[0]}admin_api{parts[1]}{link}' - print(f'`{e.text} <{fulllink}>`') + if output == 'rst': + rst = f'`{e.text} <{fulllink}>`' + print(rst) + # csv format also adds some spacing in front of links + if output == 'csv': + left_col = f' `{e.text} <{fulllink}>`' + print(f'{left_col},') + # Final spacing only with these formats + if output in ['default', 'rst']: print() - print() - print() - print() #print(soup.prettify())