This is a web crawler that is used to build a news-database from the SPIEGEL International website: https://www.spiegel.de/international/
We want to automatically trigger the web crawler to collect relevant news data and store it in our local database every 15 minutes when it is running. We want to extract news entries from HTML:
- Subtitle
- Title
- Abstract
- Download Time
- Update Time
These entries are stored in a SQLite database with the following data format:
subtitle TEXT NOT NULL PRIMARY KEY, title TEXT, abstract TEXT, download_time TIMESTAMP, update_time TIMESTAMP
• Python3 for crawler (Beautiful soup, re, requests, time, sys, unidecode, datetime)
• SQLite for Data Storage (sqlite3)
• This crawler can handle duplicate entries, different containers for news articles and also collect data from articles that may have missing Abstract, etc.
• It can also be used on any of the 500 pages of the SPIEGEL International website, we just need to edit the url as shown:
https://www.spiegel.de/international/p{$PAGE_NUMBER}/
For example: For page 2: https://www.spiegel.de/international/p2/
The rest of the code will work just as before after updating the URL.
• This crawler automatically run every 15 minutes, till the user stops the code when prompted to continue.
This program while running, may ask the user the following:
Do you want to continue (enter 'y' or 'n'):
This is to stop the program as per the user's wishes. So to stop the program, please enter: n and to keep the program running, please enter: y.
-
Download the zip folder from git clicking on
Codeas shown: -
Extract files from the zip folder downloaded. (Please make sure to keep the database file:
News.dbin the same folder as the code files) -
Open the
Command Prompton your local machine, in the folder with the extracted code files, and download the required libraries by running therequirements.txtas shown in the command prompt:pip install -r requirements.txt
-
Then run the
Crawler.pyfile to start the crawler as shown: (Input)python Crawler.py -
To view the contents of the table
test1run the following on the Command Prompt: (Output)python Database.py
For machines with both Python3 and Python2.7 installed, to run the code files, the command might have to be run as shown on the Command Prompt:
- For Crawler:
python3 Crawler.py - For Database:
python3 Database.py

