

Save the code as RSS-Feed-Reader.py and click Run to start. start_server(main, port=8080, debug=True)ġ4. The port is set to 8080, and debugging is enabled via the Python shell and on our web page. The arguments are our “main” function which will create the table from the RSS data. Outside of the function, call PyWebIO’s “start_server” function, and pass it three arguments.

put_link('Data provided by RPiLocator',url='')ġ3. Use “put_link” to create a hyperlink under the table, in this case it takes us to the source of the Raspberry Pi stock levels, rpilocator. Use PyWebIO’s “put_table” function to create an HTML table from our table object. , put_link(category,url=in_stock_link)],ġ1. Using “put_link” we create an HTML hyperlink, with the link text being the name of the reseller, stored in the category list, and the address stored in in_stock_link. In stock will print a brief description of what is in stock. The first row are the column headings Details and URL. Create a list, “table” and use it to store two columns of data, taken from our in_stock, in_stock_link and category lists. We can use this function to write any HTML elements to the page, but do take note that the PyWebIO module has many different means to create specialist elements. Use “put_html” to write an HTML H1 heading element to the web page. toast('🍓I found Raspberry Pi in stock!🍓')ĩ. The message can be a mixture of a strong, and even emojis. Outside of the for loop, create a pop-up notification using “toast”. In_stock_link.append(stock)Ĭategory.append(stock)Īn example of the RSS feed data viewed in Google Chrome (Image credit: Tom's Hardware)Ĩ. The data stored in a dictionary requires us to know the key (‘entries’ for example). This will count from 0 to 4 as the for loop iterates. For the data in a list we can use its numerical index, which is the value of i in our for loop. The RSS data stored in “stock” is a mixture of lists and dictionaries. Use “append” to add the stock status, link and category (reseller name) to the appropriate list.

Create a for loop that will iterate five times. These will be used to store the data retrieved from the “stock” object containing the RSS data. Create three empty lists, in_stock, in_stock_link and category. Inside the function create an object, “stock” and use it to store the parsed output of the rpilocator RSS feed. The pywebio.output module is used to generate HTML elements such as tables and hyperlinks. The first contains the code to start a simple web server. In a new blank document, import two modules from pywebio. We will grab the current five entries and display them in an HTML table, created using Python.ġ. Our goal is to create a Python project that will use the data from rpilocator’s RSS feed to populate a table.
