![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Chilkat2-Python) Read RSS FeedNote: This example uses classes, properties, or methods discontinued in Chilkat v11.0.0 or greater. Sample code showing how to read an RSS feed and emit the contents.
import sys import chilkat2 rss = chilkat2.Rss() # Download from the feed URL: success = rss.DownloadRss("http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml") if (success != True): print(rss.LastErrorText) sys.exit() # Get the 1st channel. # rssChannel is a CkRss rssChannel = rss.GetChannel(0) if (rss.LastMethodSuccess == False): print("No channel found in RSS feed.") sys.exit() # Display the various pieces of information about the channel: print("Title: " + rssChannel.GetString("title")) print("Link: " + rssChannel.GetString("link")) print("Description: " + rssChannel.GetString("description")) # For each item in the channel, display the title, link, # publish date, and categories assigned to the post. numItems = rssChannel.NumItems for i in range(0,numItems): # rssItem is a CkRss rssItem = rssChannel.GetItem(i) print("----") print("Title: " + rssItem.GetString("title")) print("Link: " + rssItem.GetString("link")) print("pubDate: " + rssItem.GetString("pubDate")) numCategories = rssItem.GetCount("category") if (numCategories > 0): for j in range(0,numCategories): print(" category: " + rssItem.MGetString("category",j)) |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.