This project provides a Python script that scrapes the Japan Customs website to extract Harmonized System (HS) codes and their descriptions for the 2025 tariff schedule.
The script (hs_code_exporter.py) performs the following tasks:
- Scrapes the Japan Customs website (2025 version)
- Extracts HS codes at different levels (HS2, HS4, and HS6)
- Collects corresponding descriptions for each code
- Exports the data to an Excel file
- Scrapes all chapters from the Japan Customs website
- Handles hierarchical HS code structure (2-digit, 4-digit, and 6-digit codes)
- Organizes data by sections and chapters
- Exports data to Excel format for easy analysis
- Includes error handling for failed requests
- Progress tracking during scraping
- Python 3.6 or higher
- Required Python packages are listed in
requirements.txt
- Clone this repository or download the source code
- Install the required packages:
pip install -r requirements.txtRun the script using Python:
python hs_code_exporter.pyThe script will:
- Start scraping from the main page
- Process each chapter sequentially
- Create an Excel file named
HS_2025_Japan_codes.xlsxwith the results
The generated Excel file contains the following columns:
HS2: 2-digit HS code (chapter level)HS4: 4-digit HS code (heading level)HS6: 6-digit HS code (subheading level)Description: Description of the HS code
The data is sourced from the Japan Customs website:
- Base URL: https://www.customs.go.jp/english/tariff/2025_04_01/
- Data version: 2025 (Effective from April 1, 2025)
- The script includes a
save_main_page_html()function for debugging purposes (commented out by default) - Internet connection is required to run the script
- Processing time depends on the network speed and server response time
The script includes error handling for:
- Failed HTTP requests
- Missing or malformed data
- Network connectivity issues
Each failed scraping attempt for a chapter is logged but doesn't stop the overall process.