Skip to content

Instantly share code, notes, and snippets.

@phwelo
Created October 25, 2021 19:53
Show Gist options
  • Select an option

  • Save phwelo/5efe5433e003456a673d090050dc7321 to your computer and use it in GitHub Desktop.

Select an option

Save phwelo/5efe5433e003456a673d090050dc7321 to your computer and use it in GitHub Desktop.

Revisions

  1. phwelo created this gist Oct 25, 2021.
    24 changes: 24 additions & 0 deletions rando.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/usr/bin/env python3

    import requests
    import json
    import random
    import webbrowser
    import sys

    # This is a query for 1.17.1 modpacks
    base_searchpage = "https://www.modpackindex.com/api/v1/minecraft/version/71/modpacks?limit=100&page="

    def get_page(page_num, url):
    full_url = url + str(page_num)
    result = requests.get(full_url).text
    return json.loads(result)["data"]

    mods_list = []
    # Grab the first 10 pages :shrug:
    for num in range(1, 11):
    result = get_page(num, base_searchpage)
    mods_list = mods_list + result

    choice = random.choice(mods_list)
    webbrowser.open(choice["url"], new=0, autoraise=True)