
The lines 3 to 7 contain the function that we get to write once parseUrl() has retrieved the data and has given us the err and feed results. Line 2 is using the parseURL() function from that library to read our feed. This is what we just imported from the library we downloaded. Line 1 shows us initializing a new RSSParser object.
#Rss feed reader python install#
If your site is a Node project, you can install it using npm by running npm install -save rss-parser, but if you’re just using a basic HTML & Javascript setup, you can download the library by navigating here, right-clicking on the “Raw” button and selecting “Save As…”.įigure 1: retrieving and printing the article titles

RSS-parser is an NPM module which does this perfectly. Fortunately, many libraries already exist which perform this function. Since we know that RSS is standardised, it follows a set of rules, so we could write a parser which understands the data from the RSS feed and then display that on the page. In the new “Blog” section of my portfolio site, I wanted to display the latest three articles from my Medium profile. The articles you read on Medium can be retrieved via RSS as well as through the browser. It’s most commonly used for news aggregators and blogs, enabling third-party platforms to display blog posts from other platforms.
#Rss feed reader python software#
RSS is an XML based data stream that is standardised so that software can always understand the data no matter where it comes from, so long as it conforms to RSS standard. These feeds can, for example, allow a user to keep track of many different websites in a single news aggregator.” - Wikipedia “RSS is a web feed that allows users and applications to access updates to websites in a standardized, computer-readable format. Fortunately, Medium provides an RSS feed for each member at the following URL where is your Medium username: is What Is RSS? However, I wanted to display my latest articles from Medium on my page. The usual stuff.Īll of the tutorials and walkthroughs I write are published on Medium. It’s used to expose my development experience, my skills and the projects I’ve worked on over the years. This is most likely not the cleanest implementation, just a heads up.I, like many developers, have a portfolio site which doubles up as a kind of CV/Resume.
#Rss feed reader python full#
Print("Errror:fetchxmlasstring ".format(url)) Run Script Running python script for RSS Feed GUI Full Code However when the status code is 2xx no error is thrown after response.raise_for_status call. Unlike JS where any bad response (4xx and 5xx status code) gets thrown as an error, you would have to raise the status to get a similar experience using the requests module. Since we are simply retrieving data, the HTTP verb GET should suffice. Once the url has been validated and cleaned up, we can make requests. Return url Fetch the xml file at the user’s url

This function ensures there are no trailing / characters at the end of the user’s url.

Return scheme in allowedscheme Remove trailing slashes Therefore with the urlparse module, I can extract the protocol or scheme from the user’s input and check if it is either an http or https scheme. Validate Urlīefore making any requests, we have to know if it points to something. This method simply retrieves the user’s url. Userinput: str = input("Type in a valid url ") Solution Get url from user def geturlfromuser() -> str:
