I needed a country code to do a certain competition. I wondered if I would have a chance to use it in the future, so I made it.
Created with a function. Scraping source
Python jupyterCode
country_code.ipynb
def country_code(output,file_name):
'''
***help***
output :Currently csv only
file_name :Get any file name
The pandas I'm using this time.read_html is lxml, html5lib,
beautifulsoup4 is required, so install it with pip
'''
import pandas as pd
url = "https://www-yousei.jsps.go.jp/yousei1/kuniList.do"
dfs = pd.read_html(url,header = 0)
if output == "csv":
dfs[0].to_csv(file_name + ".csv")
return dfs[0]
Since it is also uploaded to Git, it would be helpful if you could raise the code to get other codes if you are interested. GitHub Link
I'm new to GitHub and there are many things I don't understand, so if you have any questions, please let me know in the comments.
Recommended Posts