Programming the Raspberry Piâ¢: Getting Started with Python by Simon Monk
When you run this, you will mostly get a list of products. If you really get into this kind of thing, then search for âRegular Expressions in Pythonâ on the Internet. Regular expressions are almost a language in their own right; they are used for doing complex searches and validations of text. They are not easy to learn or use, but they can simplify tasks like this one.
What we have done here is called web scraping, and it is not ideal for a number of reasons. First of all, organizations often do not like people âscrapingâ their web pages with automated programs. Therefore, you may get a warning or even banned from some sites.
Second, this action is very dependent on the structure of the web page. One tiny change on the website and everything could stop working. A much better approach is to look for an official web service interface to the site. Rather than returning the data as HTML, these services return much more easily processed data, often in XML or JSON format.
If you want to learn more about how to do this kind of thing, search the Internet for âweb services in Python.â