Created
August 25, 2023 15:38
-
-
Save holly/2d5da7ca53ecacaf93a6457e9aa8f8d2 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 python | |
import os | |
import sys | |
import requests | |
import csv | |
from bs4 import BeautifulSoup | |
URL = "https://jprs.jp/registration/list/meibo/meibo_list_{0}.html" | |
PAGES = [ "a", "ka", "sa", "ta", "na", "ha", "ma", "ya", "ra", "wa" ] | |
HEADER = ["指定事業者", "汎用", "都道府県型", "日本語", "AC", "AD", "CO", "ED", "GO", "GR", "NE", "OR", "地域型", "ドメイン名登録のみ", "ホスティングサービス", "IPv6ホスト情報登録", "IPv6接続", "DNSSEC署名鍵", "DNSSEC権威DNS", "DNSSECキャッシュDNS" ] | |
writer = csv.writer(sys.stdout) | |
writer.writerow(HEADER) | |
for page in PAGES: | |
url = URL.format(page) | |
res = requests.get(url) | |
content = res.content | |
soup = BeautifulSoup(content, "html.parser") | |
tables = soup.find_all("table", class_="tb-sml") | |
for table in tables: | |
rows = table.find_all("tr") | |
for row in rows: | |
cols = row.find_all("td") | |
writer.writerow( [ col.text.strip() for col in cols ] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment