This Python script reads an Excel file, extracts domain names from URLs in the specified column (C column), and counts how many times each domain appears. The results are then saved to a new Excel file.
- Python 3.x
- pandas
- openpyxl
Install the required Python packages using pip:
pip install pandas openpyxl
- Clone the repository:
git clone https://github.com/zackha/url-domain-counter-python.git
cd url-domain-counter-python
- Run the script:
python url_domain_counter.py
- Follow the prompts to select an input Excel file and specify an output file for the results.
- The script opens a file dialog for you to select an Excel file.
- It reads URLs from the C column of the selected Excel file.
- It extracts the domain names from the URLs and counts the occurrences of each domain.
- It saves the results to a new Excel file, with domain names in the A column and their counts in the B column.
Input Excel file (C column):
https://example.com/page1
https://example.com/page2
https://anotherdomain.com/page1
https://example.com/page3
Output Excel file:
Domain | Count |
---|---|
example.com | 3 |
anotherdomain.com | 1 |
This project is licensed under the MIT License.