Building a Flask Test Site and Retrieving Data with Excel and Python
This tutorial explains how to create a simple Flask web site and RESTful API, then demonstrates retrieving the table data using Excel's web import feature and Python's requests, BeautifulSoup, and pandas libraries, while comparing the two approaches.
The article demonstrates how to create a simple data‑driven web site using Python Flask, expose the data through a RESTful API, and then fetch the data either with Excel’s “From Web” feature or with Python libraries such as requests, BeautifulSoup and pandas.
First, a Flask application (file 5-5-WebTable.py ) is built that returns an HTML table containing sample user information. The script is started with python ./5-5-WebTable.py and can be accessed at http://127.0.0.1:5000/ .
Second, a Flask‑RESTPlus API (file 5-5-WebAPI.py ) is created. The code installs flask-restplus , defines a data model, implements CRUD operations in the TodoDAO class, and maps the routes / and /<int:id> . The service runs on port 8000 and is reachable at http://127.0.0.1:8000/ExcelPythonTest/ .
Third, the article shows how Excel can import the table directly from the Flask site (Data → From Web) and how Python can retrieve the same data. The Python example uses requests.get(url) to obtain the page, parses the table with BeautifulSoup, and extracts rows into a list.
Finally, the article compares the Excel and Python approaches, noting that Excel’s web‑import is limited to static tables while Python offers full control and can handle JSON responses from the API.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.