Skip to content

Instantly share code, notes, and snippets.

@shajidhasan
Last active September 10, 2022 05:50
Show Gist options
  • Save shajidhasan/686bd54d4e8c3f2a096cc8badbea8e31 to your computer and use it in GitHub Desktop.
Save shajidhasan/686bd54d4e8c3f2a096cc8badbea8e31 to your computer and use it in GitHub Desktop.

FontBD font downloading script

I needed some Bengali fonts for a project and I found it quite tiresome to download multiple fonts quickly from LipiGhor as well as FontBD. So I wrote a PYTHON script for downloading all the fonts of these websites. You may need to run pip install requests before executing the script.

The LipiGhor script is here.

# FontBD font downloader

import re
import requests
import pathlib

OUTPUT_FOLDER = "fontbd_fonts"
PAGES = 5
URL = "https://fontbd.com/free-fonts/page/"
DOWNLOAD_URL = "https://fontbd.com/download-font?cp-font-id="
REGEX = "href=\"(https://fontbd.com/free-font/.*/)\""
REGEX2 = "cp-font-id=(\d+)"

for i in range(1, PAGES+1):
    html = requests.get(URL + str(i)).text
    for link in re.findall(REGEX, html):
        font = link.split("/")[-2]
        html2 = requests.get(link).text
        download = DOWNLOAD_URL + re.search(REGEX2, html2).group(1)
        res = requests.get(download, stream=True)
        folder = pathlib.Path(OUTPUT_FOLDER)
        folder.mkdir(exist_ok=True)
        with open((folder / font).with_suffix(".zip"), "wb") as file:
            for chunk in res.iter_content(chunk_size=512):
                if chunk:
                    file.write(chunk)

        print("Downloaded:" + font.rjust(40))

print("Done!")

IMPORTANT: There are copyright rules and some conditions of these fonts. Please read here. I am not responsible for anything you do.

@Melovalent-DBP
Copy link

Great work brother , really appreciable . Keep it up .

@mubinakib5
Copy link

You have saved a tons of time <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment