Skip to content

Nachhilfe-Development/ScrapeCord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScrapeCord

ScrapeCord is a python library for generating and rendering transcripts of discord channels from a py-cord discord bot.

ScrapeCord collects data from a discord channel and stores it in a json-format. This json-format data then can be rendered to html.

Scraping

from ScrapeCord.scraper import Scraper

@bot.slash_command(name="example")
async def print_output(ctx: discord.ApplicationContext, limit: int = 10, channel: discord.TextChannel = None):
    if channel is None:
        channel = ctx.channel

    await ctx.respond(f"Scaped {limit} messages from {channel.mention}", ephemeral=True)

    scraper = Scraper(channel, limit)
    data = await scraper.scrape_channel()
    json_string = json.dumps(data, indent=4, sort_keys=True)
    print(json_string)

    with open("example.json", "w", encoding="utf-8") as f:
        f.write(json_string)

Rendering

from ScrapeCord.renderer import render_to_html

with open("example.json", "r") as f:
    data = json.load(f)

html = render_to_html(data)

with open("example.html", "w", encoding="utf-8") as f:
    f.write(html)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •