diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:38:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:38:04 +0000 |
commit | e0847dd62461001851da4c89f279e16b14c3eb4c (patch) | |
tree | 87422376dd9a7eee55850f0fce9a8bb4c13e44a2 /scripts/download_redis_commands.py | |
parent | Initial commit. (diff) | |
download | iredis-e0847dd62461001851da4c89f279e16b14c3eb4c.tar.xz iredis-e0847dd62461001851da4c89f279e16b14c3eb4c.zip |
Adding upstream version 1.13.0.upstream/1.13.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/download_redis_commands.py')
-rwxr-xr-x | scripts/download_redis_commands.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/download_redis_commands.py b/scripts/download_redis_commands.py new file mode 100755 index 0000000..4dda6b8 --- /dev/null +++ b/scripts/download_redis_commands.py @@ -0,0 +1,50 @@ +#!python3 + +""" +Download all Reids commands from https://redis.io/commands. +Output to csv format. +""" +import sys +import csv + +from lxml import etree +import requests + +stdout_writer = csv.writer(sys.stdout) + + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + + +eprint("Download https://redis.io/commands page...") +page = requests.get("https://redis.io/commands").text +eprint("Download finished!") + +eprint("Start prase page...") +html = etree.HTML(page) +commands = html.xpath("//div[@class='container']/ul/li") +stdout_writer.writerow(["Group", "Command", "Args", "Summary", "Redis.io link"]) +command_rows = [] +# parse page +for command in commands: + group = command.attrib["data-group"] + command_name = command.xpath("./a/span[@class='command']/text()")[0].strip() + command_args = command.xpath( + "./a/span[@class='command']/span[@class='args']/text()" + )[0].strip() + command_summary = command.xpath("./a/span[@class='summary']/text()")[0].strip() + command_link = "https://redis.io" + command.xpath("./a/@href")[0].strip() + command_rows.append( + [ + group, + command_name, + " ".join(command_args.split()), + command_summary, + command_link, + ] + ) +# write to stdout +for row in sorted(command_rows): + stdout_writer.writerow(row) +eprint("Down.") |