CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 09:02:18 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"b62ab3e329f1ce3fcb97b51298c3151d"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=%2FqrpMtM9bq6WsALJEPdCVvLsVA5vLLlas6xVIRt8QBIkOHukHqid%2Fu0gGny4RvEtmyp3D2E9gNl3rMfMaiXBmLmPhsr%2BRrZeNTfK3GlWI2u5YftJJGe0UMo4ptWI8l0Yy9AqRqGZctE%2F6HRTdGf%2BrK9kSXaLo9q3SeExMFZoAqpwftx7zgqoVJMITmDH5oP04DmtCRWKldqi8KtyJ3kZAOljq7UPbsxMZBdgbJLu7jWLlUNPZkXLbNrTUZVo9RqcDApnUvunRejdozFnYGNImA%3D%3D--NQ77vQHxpGD6tPPA--DJcYQgu6CKUYFU%2F08Hyx5g%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.619128978.1760173337; Path=/; Domain=github.com; Expires=Sun, 11 Oct 2026 09:02:17 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 11 Oct 2026 09:02:17 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: A552:8CC4A:4E8C70:6AB3B9:68EA1D19
w3c-licenses.py · GitHub
Show Gist options
Save mnot/7f8de5920f84ef77eea13f81016e3a5f to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Created
February 8, 2022 08:14
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save mnot/7f8de5920f84ef77eea13f81016e3a5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" Use the W3C API to understand what document licenses are in use.""" | |
import re | |
import sys | |
import time | |
from urllib.parse import urlparse, urlunparse, urljoin | |
from bs4 import BeautifulSoup, SoupStrainer | |
import requests | |
import requests_cache | |
API_KEY = "REPLACE_ME" | |
RETRY_MAX = 3 | |
RETRY_WAIT = 2 | |
s = requests_cache.CachedSession("W3C_cache") | |
ws = re.compile(r"\W+") | |
COPYRIGHT = SoupStrainer(class_="copyright") | |
def apifetch(url): | |
url = urljoin("https://api.w3.org/", url) | |
fetch_url = urlparse(url) | |
fetch_url = fetch_url._replace(query=fetch_url.query + f"&apikey={API_KEY}") | |
fetch_url = urlunparse(fetch_url) | |
headers = {"accept": "application/json"} | |
response = fetch(fetch_url, headers=headers) | |
results = response.json() | |
if "next" in results.get("_links", {}): | |
next_uri = results["_links"]["next"]["href"] | |
next_results = apifetch(next_uri) | |
results = combine_members(results, next_results) | |
return results | |
def htmlfetch(spec_details, retries=0): | |
url = spec_details["shortlink"] | |
title = spec_details["title"] | |
status = spec_details["_links"]["latest-version"]["title"] | |
group_url = spec_details["_links"]["latest-version"]["href"] + "/deliverers" | |
group = apifetch(group_url)["_links"].get("deliverers", [{"title": "Unknown"}])[0]["title"] | |
try: | |
html = fetch(url) | |
except AssertionError as why: | |
sys.stderr.write(f"* {str(why)}\n") | |
return | |
soup = BeautifulSoup(html.text, "html.parser", parse_only=COPYRIGHT) | |
license = findlicense(soup) | |
print(f"{url}\t{title}\t{group}\t{status}\t{license}") | |
def fetch(url, headers=None, retries=0): | |
try: | |
response = s.get(url, headers=headers) | |
assert response.status_code in [200, 206], f"{response.status_code} on {url}" | |
return response | |
except requests.exceptions.ConnectionError: | |
if retries > RETRY_MAX: | |
sys.stderr.write(f"Max retries for {url}; aborting.\n") | |
sys.exit(1) | |
time.sleep(RETRY_WAIT) | |
sys.stderr.write(f"Retrying {url}\n") | |
return fetch(url, headers=headers, retries=retries + 1) | |
def findlicense(copyright): | |
for tag in copyright.find_all("a"): | |
text = ws.sub(" ", tag.get_text(strip=True).strip().lower()) | |
if text in [ | |
"document use", | |
"document license", | |
"document licensing", | |
"permissive document license", | |
]: | |
return tag["href"] | |
return "Unknown" | |
def combine_members(a, b): | |
o = {"_embedded": {}} | |
for key in o: | |
for member in a[key]: | |
o[key][member] = a[key][member] + b[key].get(member, []) | |
return o | |
def main(): | |
results = apifetch("/specifications?embed=true") | |
n = 0 | |
for spec_details in results["_embedded"]["specifications"]: | |
n += 1 | |
htmlfetch(spec_details) | |
sys.stderr.write(f"{n}\n") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.