Created
January 29, 2023 06:41
-
-
Save zyouyowa/40f33e0fc074f7238ebd38c1462a0b54 to your computer and use it in GitHub Desktop.
デッキのurlからカード名と枚数を取得してcsv形式で出力するやつ
This file contains 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
#!python3 | |
from bs4 import BeautifulSoup | |
import requests | |
import sys | |
# Usage: | |
# $ python3 deck2csv.py <url> | |
def main(): | |
url = sys.argv[1] | |
res = requests.get(url) | |
soup = BeautifulSoup(res.text, "html.parser") | |
cardtags = soup.find_all('tr', class_="row") | |
for el in cardtags: | |
name = el.contents[5].text.replace("\n", "") | |
num = el.contents[7].text.replace("\n", "").replace("\t", "") | |
print(name, num, sep=',') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment