This project is a Python-based application that scrapes typhoon holiday information from the DGPA website and interacts with users through a chatbot interface. The project also includes tests for key functionalities using pytest
.
- Web Scraping: Utilizes BeautifulSoup to extract data from the specified webpage.
- Data Processing: Processes the scraped data to format it for chatbot responses.
- Chatbot Integration: Uses the Ollama API to interact with users, providing typhoon holiday information based on the latest data.
- Python 3.x
- Required Python packages:
requests
beautifulsoup4
ollama
pytest
requests_mock
You can install the necessary packages using pip:
pip install requests beautifulsoup4 ollama pytest requests_mock
- Run the Script:
- Execute the
main.py
script to start the chatbot interface.
- Execute the
python main.py
- Interaction:
- The chatbot will provide typhoon holiday information based on the latest scraped data. It responds to user queries, and if a question is outside the scope of the data, it will indicate that it does not have the information.
The project includes a test suite to verify the functionality of core components. The tests are written using pytest
and can be found in test_main.py
. To run the tests, use the following command:
pytest test_main.py
- test_fetch_html: Tests the
fetch_html
function by mocking a network response. - test_process_data: Tests the
process_data
function using sample HTML content. - test_ollama_chat: Placeholder for future tests related to the chatbot interaction.
main.py
: The main script that handles web scraping, data processing, and chatbot interaction.test_main.py
: The test script for unit testing the core functionalities usingpytest
.
Below is a screenshot of the chatbot interface in action:
If you would like to contribute to this project, please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License - see the LICENSE file for details.