CountryInfoFetcher is a Python project designed to fetch and display information about countries using the restcountries.com API. It provides details such as the country name, capital city, and a link to the flag image in PNG format, displayed in a tabular format in the console.
- Fetches country data from the restcountries.com API.
- Displays country information in a readable tabular format.
- Logs activities and errors for easy debugging and monitoring.
- Python 3.6+
requests
librarytabulate
library
-
Clone the repository:
git clone https://github.com/igor20192/CountryInfoFetcher.git cd CountryInfoFetcher
-
Install the required libraries:
pip install requests tabulate
To fetch and display the country information, run the main.py
script:
python country.py
The script will fetch data from the API and display it in the console in a tabular format, including the country name, capital city, and flag URL.
- country_info.py: Contains the CountryInfo class which handles fetching and displaying the data.
- README.md: Project documentation.
When you run the script, the output will be displayed in a table format like this:
+-----------------+----------------+-------------------------------------------------------------+
| Country Name | Capital | Flag URL |
+-----------------+----------------+-------------------------------------------------------------+
| Afghanistan | Kabul | https://flagcdn.com/w320/af.png |
| Albania | Tirana | https://flagcdn.com/w320/al.png |
| Algeria | Algiers | https://flagcdn.com/w320/dz.png |
| ... | ... | ... |
+-----------------+----------------+-------------------------------------------------------------+
The application uses Python's logging module to log information and errors. The logs include details about fetching data, any HTTP errors, connection issues, and more.
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
If you have any questions or suggestions, feel free to open an issue or contact me at [[email protected]].