Views
No views yet
git clone https://github.com/LAION-AI/Discord-Scrapers.gitpip install -r requirements.txtDISCORD_TOKEN and HF_TOKEN and add as environment variables.
DISCORD_TOKEN can be obtained by looking at developer tools in your Web BrowserHF_TOKEN can be obtained by logging in to HuggingFace and looking at your profilechannel_id from the Discord channel you want to scrape. You can do this by enabling developer mode in Discord and right clicking the channel you want to scrape.condition_fn and a parse_fn that will be used to filter and parse the messages. You can use the ones I created as an example.config.json1import os
2from typing import Any, Dict, List
3
4from scraper import ScraperBot, ScraperBotConfig, HFDatasetScheme
5
6def parse_fn(message: Dict[str, Any]) -> List[HFDatasetScheme]:
7 ...
8
9def condition_fn(message: Dict[str, Any]) -> bool:
10 ...
11
12if __name__ == "__main__":
13 config_path = os.path.join(os.path.dirname(__file__), "config.json")
14 config = ScraperBotConfig.from_json(config_path)
15
16 bot = ScraperBot(config=config, parse_fn=parse_fn, condition_fn=condition_fn)
17 bot.scrape(fetch_all=False, push_to_hub=False)ScraperBotConfig.from_json(path_to_config).condition_fn. Then parses the messages using the parse_fn and pushes the dataset to HuggingFace.HF_TOKEN environment variable.
NOTE 2: If the dataset doesn't exist in HuggingFace it will be created. If it already exists it will be updated.