Back to .md Directory

Midjourney Prompt Scraper

Scrapes Midjourney prompts from prompthero.com, extracts subjects with spaCy, and converts the data to JSONL for language model fine-tuning.

May 2, 2026
0 downloads
1 views
ai llm prompt
View source

What this file does

Scrapes Midjourney prompts from prompthero.com, extracts subjects with spaCy, and converts the data to JSONL for language model fine-tuning.

When to use it

  • Building a dataset of image generation prompts for LLM training
  • Extracting and cleaning prompt text from a public gallery website
  • Adding subject identification to raw prompt collections
  • Converting scraped CSV data into Hugging Face compatible JSONL format

Assumes this stack

PythonSeleniumBeautifulSoupspaCyNLTKHugging Face Transformers

Midjourney Prompt Scraper

Overview

This project involves the extraction, processing, and transformation of Midjourney prompts obtained from https://prompthero.com/midjourney-prompts. The goal is to create a dataset suitable for training language models, specifically tailored for image generation prompts.

Project Structure

The project consists of four Python scripts:

  1. link_extracter.py

    • Description: Scrapes prompt links from the Midjourney prompts website using Selenium and BeautifulSoup.
    • Dependencies: csv, BeautifulSoup, selenium
  2. text_extracter.py

    • Description: Fetches text content from the extracted prompt links, considering rate-limiting and retries.
    • Dependencies: csv, requests, BeautifulSoup, time, HTTPAdapter, Retry
  3. addsubject.py

    • Description: Identifies main subjects in the prompts using spaCy and NLTK, then replaces placeholders with these subjects.
    • Dependencies: csv, spacy, nltk
  4. convert2json.py

    • Description: Converts the processed CSV data into a JSON format suitable for training a language model.
    • Dependencies: csv, json

Usage

  1. Clone the Repository:

    git clone [repository_url]
    cd Midjourney-Prompts-Project
    
  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Run the Scripts:

    python link_extracter.py
    python text_extracter.py
    python addsubject.py
    python convert2json.py
    
  4. Generated Files:

    • prompt_links.csv: Contains the extracted prompt links.
    • partial_prompt_texts.csv: Contains text extracted from the prompt links.
    • prompts_with_subject.csv: Contains prompts with identified subjects.
    • prompts_with_subject.jsonl: JSON file suitable for language model training.

Hugging Face Dataset Card

Explore the dataset on Hugging Face: Midjourney Art Prompts

Dataset Usage

The generated JSON file is specifically formatted for fine-tuning models using Hugging Face's Transformers library, such as ChatGPT. The CSV files, on the other hand, can be used for training or fine-tuning other Language Model Models (LLMs).

Acknowledgments

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

What's inside

4 Python scripts (link extraction, text extraction, subject identification, JSON conversion) plus a Hugging Face dataset link.

Change this for your project

  • Replace https://prompthero.com/midjourney-prompts with your target URL
  • Replace mshojaei77/Midjourney-Art-Prompts with your Hugging Face dataset ID
  • Replace mshojaei77 in repository references with your own GitHub username

Where it goes

Keep it in your repository where the agent or team that needs it will read it.

Worth borrowing

  • Rate-limiting and retry logic in text_extracter.py to avoid being blocked
  • Using spaCy and NLTK together to identify main subjects from prompt text

Related Documents