Monorepo for Tangled tangled.org
758
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Feature Request]: Raw Content URLs #183

open opened by zzstoatzz.io

cool project :)

on github you can get a file's code via raw.githubusercontent.com which can be useful

# /// script
# requires-python = ">=3.8"
# dependencies = ["requests", "bs4"]
# ///
import requests
from bs4 import BeautifulSoup
import html

def extract_tangled_code(url: str) -> str:
    if not (code_divs := BeautifulSoup(requests.get(url).text, "html.parser").select("div.whitespace-pre")):
        return "no code divs :/"
    return "\n".join(html.unescape(div.get_text(strip=False)) for div in code_divs)

print(
    extract_tangled_code(
        "https://tangled.sh/@alternatebuild.dev/mcpsrvrs/blob/main/fetch.py"
    )
)

lmk if there's a way I'm missing or if this is out of scope - ty!

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xbtmt2zjwlrfegqvch7fboei/sh.tangled.repo.issue/3lkpa42zrcu22