Initial commit (Move from other Repository)
This commit is contained in:
commit
4900d81eaa
52 files changed
+26138
No files matched your search
+7022
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib.parse import urlparse
|
||||
|
||||
URL = "https://material-theme.com/docs/reference/associations/"
|
||||
DATA_FILE = "icons.json"
|
||||
|
||||
def scrape_icons():
|
||||
print(f"Connecting to {URL}...")
|
||||
response = requests.get(URL)
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
|
||||
rows = soup.select("tbody tr")
|
||||
associations = []
|
||||
|
||||
print(f"Found {len(rows)} potential icons. Starting download...")
|
||||
|
||||
for row in rows:
|
||||
cols = row.find_all("td")
|
||||
if len(cols) < 4:
|
||||
continue
|
||||
|
||||
name = cols[0].get_text(strip=True)
|
||||
pattern = cols[1].find("code").get_text(strip=True) if cols[1].find("code") else cols[1].get_text(strip=True)
|
||||
img_tag = cols[3].find("img")["src"]
|
||||
|
||||
associations.append({
|
||||
"name": name,
|
||||
"pattern": pattern,
|
||||
"icon_path": img_tag
|
||||
})
|
||||
print(f"Saved: {name}")
|
||||
|
||||
with open(DATA_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(associations, f, indent=4)
|
||||
|
||||
print(f"\nFinished! Processed {len(associations)} icons.")
|
||||
print(f"Data saved to {DATA_FILE}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
scrape_icons()
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,36 @@
|
||||
import requests
|
||||
import yaml
|
||||
import json
|
||||
|
||||
def get_github_language_data():
|
||||
raw_url = "https://raw.githubusercontent.com/github-linguist/linguist/master/lib/linguist/languages.yml"
|
||||
output_file = "languages.json"
|
||||
|
||||
print("Fetching data from GitHub...")
|
||||
|
||||
try:
|
||||
response = requests.get(raw_url)
|
||||
response.raise_for_status()
|
||||
|
||||
full_data = yaml.load(response.text, Loader=yaml.SafeLoader)
|
||||
|
||||
clean_data = []
|
||||
|
||||
for lang_name, attr in full_data.items():
|
||||
if 'color' in attr:
|
||||
clean_data.append({
|
||||
"name": lang_name,
|
||||
"color": attr.get('color'),
|
||||
"extensions": attr.get('extensions', [])
|
||||
})
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(clean_data, f, indent=4)
|
||||
|
||||
print(f"Successfully saved {len(clean_data)} languages to {output_file}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_github_language_data()
|
||||
Reference in new issue
Block a user