working on it ...

Filters

Explore Public Snippets

Sort by

Found 831 snippets matching: rss

    public by cghersi  246975  1  6  1

    Calculate the occurrences of words in Rss feed

    Creates a dictionary with keys=words and values=occurrences of that word in the given Rss (specified by the URL). The caller should specify the maximum number of items in the returning dictionary and, optionally, the minimum length of the words that will be added to the output.
    public static Dictionary<string, int> ComputeWordsOccurrencesInRss(string url, int maxItems, int minLenOfAcceptedWords = 1)
    {
      Dictionary<string, int> occurrences = new Dictionary<string, int>();
    
      IList<RssReader.RssItem> singleRssResult = RssReader.ReadRss(url, maxItems, true);
      string[] splitted = null;
      foreach (RssReader.RssItem rss in singleRssResult)
      {
        List<string> words = new List<string>();
    
        //split title in words:
        splitted = StringHelper.SplitIntoWords(rss.Title);
        if (splitted != null)
          words.AddRange(splitted);
    
        //split summary in words:
        splitted = StringHelper.SplitIntoWords(rss.Summary);
        if (splitted != null)
          words.AddRange(splitted);
    
        //compute occurrences of words:
        for (int w = 0; w < words.Count; w++)
        {
          string word = words[w].ToLower();
          if (word.Length < minLenOfAcceptedWords)
            continue;
          if (occurrences.ContainsKey(word))
            occurrences[word]++;
          else
            occurrences.Add(word, 1);
        }
      }
    
      return occurrences;
    }
    

    public by cghersi  4629  2  6  2

    Read the content of an rss feed

    Retrieves the RSS Item at the specified URL and prepares a list of RSS Items with tile, summary and id. The caller should specify the maximum number of items to download and can decide to strip HTML from title and summary.
    public class RssReader
    {
      public class RssItem
      {
        public string Title { get; set; }
        public string Summary { get; set; }
        public string Id { get; set; }
      }
      
      /// <summary>
      /// Requires System.ServiceModel to be added as a reference
      /// </summary>
      /// <param name="url"></param>
      /// <param name="maxItems"></param>
      public static IList<RssItem> ReadRss(string url, int maxItems, bool stripHtml = false)
      {
        IList<RssItem> result = new List<RssItem>();
        XmlReader reader = XmlReader.Create(url);
        SyndicationFeed feed = null;
        try
        {
          feed = SyndicationFeed.Load(reader);
        }
        catch
        {
          return result;
        }
        finally
        {
          reader.Close();
        }
      
        int totCount = 0;
        foreach (SyndicationItem item in feed.Items)
        {
          if (totCount++ > maxItems)
            break;
          string subject = (item.Title == null ? "" : item.Title.Text);
          string summary = (item.Summary == null ? "" : item.Summary.Text);
          if (stripHtml)
            summary = HtmlHelper.RemoveHtmlTag(HtmlHelper.RemoveHtmlTag(HtmlHelper.RemoveHtmlTag(HtmlHelper.RemoveHtmlTag(HtmlHelper.RemoveHtmlTag(summary, "div"), "a"), "img"), "table"), "br");
          string id = item.Id;
          result.Add(new RssItem() { Title = subject, Summary = summary, Id = id});
        }
        return result;
      }
    }
    

    public by micurs  2283  2  6  4

    Adding a feed to a web page

    This make sure the browser recognize a feed is available on the current page.
    <link rel="alternate" 
          type="application/rss+xml"  
          href="{path to your RSS XML Feed}"
          title="{feed name}">
          

    public by cghersi  2387  0  6  2

    Find the rss item in the given url that matches the given keywords and constraints

    Downloads the RSS feed specified at the given URL and tries to find an item that matches with the given keywords. The resulting items should match at least the specified number of accepted keywords (minNumOfAcceptedKeywords). The result is returned in the three out parameters.
    public static void FindRss(string url, List<string> keywordsToMatch, int minNumOfAcceptedKeywords,
      out string title, out string summary, out string id)
    {
      title = string.Empty;
      summary = string.Empty;
      id = string.Empty;
    
      //fill an array of lowercase keywords to match:
      List<string> lowerKeys = new List<string>();
      foreach(string key in keywordsToMatch)
      {
        lowerKeys.Add(key.ToLower());
      }
    
      //read the rss:
      IList<RssReader.RssItem> singleRssResult = RssReader.ReadRss(url, int.MaxValue, true);
    
      //search for the first matching item the keywords
      foreach (RssReader.RssItem rss in singleRssResult)
      {
        int matches = 0;
        string rssTitle = rss.Title.ToLower();
        string rssSummary = rss.Summary.ToLower();
        foreach (string keyword in lowerKeys)
        {
          //look in the title:
          int pos = rssTitle.IndexOf(keyword);
          if (pos > 0)
          {
            matches++;
            continue;
          }
    
          //if not found, look in the summary:
          pos = rssSummary.IndexOf(keyword);
          if (pos > 0)
          {
            matches++;
            continue;
          }
        }
    
        //check that the minimum amount of keywords has been matched:
        if (matches >= minNumOfAcceptedKeywords)
        {
          title = rss.Title;
          summary = rss.Summary;
          id = rss.Id;
          return;
        }
      }
    }
    

    public by cghersi  2044  0  5  0

    AutoCoder: Send Most Popular RSS feed via Twitter

    This is the program, created thru AutoCoder, to compute and send via Tiwtter the most popular RSS feed
    <MethodSpec UserID="1007" Name="RssTwitter" OutputType="void" xmlns="http://www.snip2code.com/ns/snip">
    	<Block ID="Seq38" BlockType="Seq">
    		<Block ID="Expr1" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203926">
    			<OutputValue/>
    			<InputArgs>
    				<Var Name="$$$input$$$Snip203926_2252" Type="var" DefaultValue="Start Reading File Containing RSS Feeds..." ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</InputArgs>
    		</Block>
    		<Block ID="Assign2" BlockType="Assign">
    			<LeftOp>
    				<Var Name="feeds" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</LeftOp>
    			<RightOp>
    				<Block ID="Expr3" BlockType="Expression" MethodName="" OutputType="var" IsLiteral="false" SnippetID="203921">
    					<OutputValue/>
    					<InputArgs>
    						<Var Name="$$$input$$$Expr3_8953" Type="var" DefaultValue="d:\AutoCoder\RssUrls.txt" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    					</InputArgs>
    				</Block>
    			</RightOp>
    		</Block>
    		<Block ID="Expr6" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203926">
    			<OutputValue/>
    			<InputArgs>
    				<Var Name="$$$input$$$Snip203926_1780" Type="var" DefaultValue="Start Reading RSS Feeds..." ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</InputArgs>
    		</Block>
    		<Block ID="Loop11" BlockType="Loop">
    			<Condition/>
    			<LoopingCollection>
    				<Var Name="feeds" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</LoopingCollection>
    			<LoopVar>
    				<Var Name="feed" Type="string" DefaultValue="null" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="true"/>
    			</LoopVar>
    			<Body>
    				<Block ID="Seq10" BlockType="Seq">
    					<Block ID="Assign7" BlockType="Assign">
    						<LeftOp>
    							<Var Name="occurrences" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</LeftOp>
    						<RightOp>
    							<Block ID="Expr8" BlockType="Expression" MethodName="" OutputType="var" IsLiteral="false" SnippetID="203916">
    								<OutputValue/>
    								<InputArgs>
    									<Var Name="feed" Type="string" DefaultValue="null" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="true"/>
    									<Var Name="$$$input$$$Expr8_3512" Type="var" DefaultValue="20" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    									<Var Name="$$$input$$$Expr8_5370" Type="var" DefaultValue="4" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    								</InputArgs>
    							</Block>
    						</RightOp>
    					</Block>
    					<Block ID="Expr9" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203923">
    						<OutputValue/>
    						<InputArgs>
    							<Var Name="totalOccurrences" Type="Dictionary&lt;string, int&gt;" DefaultValue="new Dictionary&lt;string, int&gt;()" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    							<Var Name="occurrences" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</InputArgs>
    					</Block>
    				</Block>
    			</Body>
    		</Block>
    		<Block ID="Expr12" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203926">
    			<OutputValue/>
    			<InputArgs>
    				<Var Name="$$$input$$$Snip203926_7990" Type="var" DefaultValue="Sorting Popular Words" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</InputArgs>
    		</Block>
    		<Block ID="Assign13" BlockType="Assign">
    			<LeftOp>
    				<Var Name="mostPopularWords" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</LeftOp>
    			<RightOp>
    				<Block ID="Expr14" BlockType="Expression" MethodName="" OutputType="var" IsLiteral="false" SnippetID="203920">
    					<OutputValue/>
    					<InputArgs>
    						<Var Name="totalOccurrences" Type="Dictionary&lt;string, int&gt;" DefaultValue="new Dictionary&lt;string, int&gt;()" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    						<Var Name="$$$input$$$Expr14_3209" Type="var" DefaultValue="30" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    					</InputArgs>
    				</Block>
    			</RightOp>
    		</Block>
    		<Block ID="Expr15" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203926">
    			<OutputValue/>
    			<InputArgs>
    				<Var Name="$$$input$$$Snip203926_4875" Type="var" DefaultValue="Finding the best matching article" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    			</InputArgs>
    		</Block>
    		<Block ID="Loop24" BlockType="Loop">
    			<Condition>string.IsNullOrEmpty(title)&amp;&amp;(minNumOfAcceptedKeywords&gt;0)</Condition>
    			<Body>
    				<Block ID="Seq23" BlockType="Seq">
    					<Block ID="Loop20" BlockType="Loop">
    						<Condition/>
    						<LoopingCollection>
    							<Var Name="feeds" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</LoopingCollection>
    						<LoopVar>
    							<Var Name="feed" Type="string" DefaultValue="null" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="true"/>
    						</LoopVar>
    						<Body>
    							<Block ID="Seq19" BlockType="Seq">
    								<Block ID="Expr16" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203919">
    									<OutputValue/>
    									<InputArgs>
    										<Var Name="feed" Type="string" DefaultValue="null" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="true"/>
    										<Var Name="mostPopularWords" Type="var" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    										<Var Name="minNumOfAcceptedKeywords" Type="int" DefaultValue="10" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    										<Var Name="title" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    										<Var Name="summary" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    										<Var Name="id" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    									</InputArgs>
    								</Block>
    								<Block ID="If17" BlockType="If">
    									<Condition>!string.IsNullOrEmpty(title)</Condition>
    									<Then>
    										<Block ID="Expr18" BlockType="Expression" MethodName="break" OutputType="void" IsLiteral="true" SnippetID="0">
    											<OutputValue/>
    											<InputArgs/>
    										</Block>
    									</Then>
    								</Block>
    							</Block>
    						</Body>
    					</Block>
    					<Block ID="Assign21" BlockType="Assign">
    						<LeftOp>
    							<Var Name="minNumOfAcceptedKeywords" Type="int" DefaultValue="10" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    						</LeftOp>
    						<RightOp>
    							<Block ID="Expr22" BlockType="Expression" MethodName="-" OutputType="int" IsLiteral="false" SnippetID="-1">
    								<OutputValue/>
    								<InputArgs>
    									<Var Name="minNumOfAcceptedKeywords" Type="int" DefaultValue="10" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    									<Var Name="$$$input$$$Expr22_9182" Type="var" DefaultValue="1" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    								</InputArgs>
    							</Block>
    						</RightOp>
    					</Block>
    				</Block>
    			</Body>
    		</Block>
    		<Block ID="If37" BlockType="If">
    			<Condition>string.IsNullOrEmpty(title)</Condition>
    			<Then>
    				<Block ID="Expr25" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203926">
    					<OutputValue/>
    					<InputArgs>
    						<Var Name="$$$input$$$Snip203926_6238" Type="var" DefaultValue="Cannot find any Rss feed with popular news!" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    					</InputArgs>
    				</Block>
    			</Then>
    			<Else>
    				<Block ID="Seq36" BlockType="Seq">
    					<Block ID="Assign26" BlockType="Assign">
    						<LeftOp>
    							<Var Name="curTime" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</LeftOp>
    						<RightOp>
    							<Block ID="Expr27" BlockType="Expression" MethodName="" OutputType="string" IsLiteral="false" SnippetID="207357">
    								<OutputValue/>
    								<InputArgs/>
    							</Block>
    						</RightOp>
    					</Block>
    					<Block ID="Assign28" BlockType="Assign">
    						<LeftOp>
    							<Var Name="texttoSend" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</LeftOp>
    						<RightOp>
    							<Block ID="Expr29" BlockType="Expression" MethodName="+" OutputType="string" IsLiteral="false" SnippetID="-1">
    								<OutputValue/>
    								<InputArgs>
    									<Var Name="$$$input$$$Expr29_5965" Type="var" DefaultValue="My thought of " ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    									<Var Name="curTime" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    									<Var Name="$$$input$$$Expr29_38" Type="var" DefaultValue=", what do you think about this: " ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    									<Var Name="title" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    								</InputArgs>
    							</Block>
    						</RightOp>
    					</Block>
    					<Block ID="Assign30" BlockType="Assign">
    						<LeftOp>
    							<Var Name="texttoSend" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</LeftOp>
    						<RightOp>
    							<Block ID="Expr31" BlockType="Expression" MethodName="" OutputType="string" IsLiteral="false" SnippetID="203924">
    								<OutputValue/>
    								<InputArgs>
    									<Var Name="texttoSend" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    									<Var Name="$$$input$$$Expr31_7868" Type="var" DefaultValue="140" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    								</InputArgs>
    							</Block>
    						</RightOp>
    					</Block>
    					<Block ID="Assign32" BlockType="Assign">
    						<LeftOp>
    							<Var Name="debugText" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</LeftOp>
    						<RightOp>
    							<Block ID="Expr33" BlockType="Expression" MethodName="+" OutputType="string" IsLiteral="false" SnippetID="-1">
    								<OutputValue/>
    								<InputArgs>
    									<Var Name="$$$input$$$Expr33_4701" Type="var" DefaultValue="Sending twitt:" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    									<Var Name="texttoSend" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    								</InputArgs>
    							</Block>
    						</RightOp>
    					</Block>
    					<Block ID="Expr34" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203926">
    						<OutputValue/>
    						<InputArgs>
    							<Var Name="debugText" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</InputArgs>
    					</Block>
    					<Block ID="Expr35" BlockType="Expression" MethodName="" OutputType="void" IsLiteral="false" SnippetID="203918">
    						<OutputValue/>
    						<InputArgs>
    							<Var Name="texttoSend" Type="string" DefaultValue="0" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    							<Var Name="$$$input$$$Snip203918_7323" Type="var" DefaultValue="cRCpzJcafEOWDLKes1FWblTts" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    							<Var Name="$$$input$$$Snip203918_8840" Type="var" DefaultValue="K7xgwnbAr6GDHdNQhsleDMDlaxYLQHANw6Q5wElIpoZ81VxZ34" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    							<Var Name="$$$input$$$Snip203918_6484" Type="var" DefaultValue="17482477-pGv8XQjPd0EQkLkOykteXJ7KBNxqYUtrMt1sfTabe" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    							<Var Name="$$$input$$$Snip203918_4787" Type="var" DefaultValue="fmbr63keiQcqqLVjeCxyY5H9g2Do0YWtll5pcTlgexfIL" ParamType="In" IsConst="false" Scope="Block" ValueIsNull="false"/>
    						</InputArgs>
    					</Block>
    				</Block>
    			</Else>
    		</Block>
    	</Block>
    	<InputArgs/>
    	<Vars>
    		<Var Name="totalOccurrences" Type="Dictionary&lt;string, int&gt;" DefaultValue="new Dictionary&lt;string, int&gt;()" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    		<Var Name="minNumOfAcceptedKeywords" Type="int" DefaultValue="10" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    		<Var Name="title" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    		<Var Name="summary" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    		<Var Name="id" Type="string" DefaultValue="" ParamType="In" IsConst="false" Scope="Method" ValueIsNull="false"/>
    	</Vars>
    </MethodSpec>         

    public by Shambles  3615  1  6  4

    RSS Feed Search

    google.load('feeds', '1');
    var feedList = new Array();
    
    	function resetfeeds() {			  
    	  	$("#results").fadeOut('slow', function() {
    			$('#feedQuery').val("").focus();
    			$("#results").empty();
    		});
    	  return false;
    	}
    
    	function samplefeeds() {		
    	  $('#feedQuery').val($(this).attr("rel"));
    	  findfeeds();
    	  return false;
    	}
    
    	function findfeeds() {		
    	  //need to extend this to deal with CSV
    	  //input will come from the user model in UI5
    	  var q = $.trim($('#feedQuery').val());
    	  if(q == "") {
    		  resetfeeds();
          	  return false;
    	  }
    
    
    //The following is the search based on the params above.
    	  google.feeds.findFeeds(q, function(result) {
    	  if (!result.error) {
    		var html = '';
    		for (var i = 0; i < result.entries.length; i++) {
    		  var entry = result.entries[i];
    		  feedList[i] = entry.url;
    		  var count = i+1;
    		  html += '<div id="feed-' + i + '">';
    		  html += '	<h3><img src="//s2.googleusercontent.com/s2/favicons?domain=' + entry.link + '"/> <a target="_blank" href="' + entry.link + '">' + removeHTMLTags(entry.title) + '</a></h3>';
    		  html += '	<p class="snippet">' + removeHTMLTags(entry.contentSnippet) + '</p>';
    		  html += '	<p class="feedURL">';
    		  html += '<a href="' + entry.url + '" target="_blank">RSS Feed</a> &sdot; ';
    		  html += ' <span class="showhide" rel="' + i + '">Preview Feed</span></p>';
    		  html += ' <div id="feedcontent-' + i + '"></div>';
    		  html += '</div>';
    		}
    	
    		$("#results").fadeOut('slow', function() {
    			$('html, body').animate({scrollTop:0}, 'slow');
    			$("#results").empty();
    			$("#results").append(html);
    			$("#results").show();
    		}); 	
    	   }
    			$('#pleasewait').hide();   
    	});
    	  return false;
    	}    
    
    
    	function removeHTMLTags(html){
     		var cleanHTML = 
    			html.replace(/&(lt|gt);/g, function (strMatch, p1){
     		 		return (p1 == "lt")? "<" : ">";
    				});
     		return cleanHTML.replace(/<\/?[^>]+(>|$)/g, "");
    	}
    
        function getfeed(i) {
    		var divcount = 'div#feedcontent-' + i + " > div";
    		if($(divcount).length > 0) {
    				$('div#feedcontent-' + i).animate({"height": "toggle"}, { duration: 500 });
    				if($('div#feed-' + i).find("span.showhide").text() == "Preview Feed") 
    				   $('div#feed-' + i).find("span.showhide").text("Hide Feed Preview"); 				
    				else
    				   $('div#feed-' + i).find("span.showhide").text("Preview Feed"); 
    			return;
    		}
    		var feedURL = feedList[i];
    		var feed = new google.feeds.Feed(feedURL);
    		feed.setNumEntries(20) 
    		var html = '';
    		
    		feed.load(function(result) {
    			if (!result.error) {
    				for (var c = 0; c < result.feed.entries.length; c++) {
    					var entry = result.feed.entries[c];
    					var ct = c+1;
    					html += '<div id="item-' + c + '"><h4>' + ct + '. <a target="_blank" href="' + entry.link + '">';
    					html += entry.title + '</a> ' + entry.publishedDate.substring(5,16) + '</h4><!-- <small>' + entry.contentSnippet + '</small> --></div>';
    				}
    				$('div#feedcontent-' + i).addClass("feedItems").append(html);
    				$('div#feed-' + i).find("span.showhide").text("Hide Feed Preview"); 				
    			}
    		});
    	}
    
      $(document).ready(function(){
    
        $('#feedQuery').keypress(function(e) {
            if(e.which == 13) {
                jQuery(this).blur();
                jQuery('#searchBtn').focus().click();
                return false;
            }
        });
    
        $("#searchBtn").click(findfeeds);
        $("h1").click(resetfeeds);
        $(".examples").click(samplefeeds);
    
    	$("span.showhide").live("click", function(event) {
    		getfeed($(this).attr("rel"));
    	});
    	
        $('#feedQuery').focus();
    
    });
    
    
    var timer;
    $('#feedQuery').keyup(function(){
       timer && clearTimeout(timer);
       timer = setTimeout(findfeeds, 400);
    });           

    public by Shambles  2709  1  6  1

    parse RSS ajax and javascript

    function parseRSS(url, callback) {
      $.ajax({
        url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
        dataType: 'json',
        success: function(data) {
          callback(data.responseData.feed);
        }
      });
    }

    public by Ilya N. Zykin  763  0  3  0

    RSS FEEDS

    RSS FEEDS: rss feeds.md
    ```ruby
        scope :for_yandex_news, -> {
          published.
          recent(:created_at).
          where(yandex_news: true).
          where("published_at >= ?", 8.days.ago.utc)
        }
    
        scope :for_flipboard_tech, -> {
          published.
          recent(:created_at).
          where(flipboard_tech: true).
          where("published_at >= ?", 14.days.ago.utc)
        }
    
        scope :for_flipboard_culture, -> {
          published.
          recent(:created_at).
          where(flipboard_culture: true).
          where("published_at >= ?", 14.days.ago.utc)
        }
    
        scope :for_surfingbird, -> {
          published.
          recent(:created_at).
          where(surfingbird: true).
          where("published_at >= ?", 14.days.ago.utc)
        }
    
        scope :for_novoteka, -> {
          published.
          recent(:created_at).
          where(novoteka: true).
          where("published_at >= ?", 2.month.ago.utc)
        }
    ```
    
    

    public by msdn  1697  0  6  0

    GetRssItems: Gets the RSS items.

    Gets the RSS items. The RSS feed. The on get RSS items completed. The on error.
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net;
    using System.ServiceModel.Syndication;
    using System.Xml;
    
    /// <summary>
    /// Gets the RSS items.
    /// </summary>
    /// <param name="rssFeed">The RSS feed.</param>
    /// <param name="onGetRssItemsCompleted">The on get RSS items completed.</param>
    /// <param name="onError">The on error.</param>
    private static void GetRssItems(string rssFeed, Action<IEnumerable<RssItem>> onGetRssItemsCompleted = null, Action<Exception> onError = null, Action onFinally = null)
    {
        WebClient webClient = new WebClient();
    
        // register on download complete event
        webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                // report error
                if (e.Error != null)
                {
                    if (onError != null)
                    {
                        onError(e.Error);
                    }
                    return;
                }
    
                // convert rss result to model
                List<RssItem> rssItems = new List<RssItem>();
                Stream stream = e.Result;
                XmlReader response = XmlReader.Create(stream);
                SyndicationFeed feeds = SyndicationFeed.Load(response);
                foreach (SyndicationItem f in feeds.Items)
                {
                    RssItem rssItem = new RssItem(f.Title.Text, f.Summary.Text, f.PublishDate.ToString(), f.Links[0].Uri.AbsoluteUri);
                    rssItems.Add(rssItem);
                }
    
                // notify completed callback
                if (onGetRssItemsCompleted != null)
                {
                    onGetRssItemsCompleted(rssItems);
                }
            }
            finally
            {
                // notify finally callback
                if (onFinally != null)
                {
                    onFinally();
                }
            }
        };
    
        webClient.OpenReadAsync(new Uri(rssFeed));
    }

    public by msdn  1437  0  7  0

    ParseRssDate: RSS has a specific DateTime format - this method pulls out the DateTime from that provided

    RSS has a specific DateTime format - this method pulls out the DateTime from that provided Incoming RSS DateTime Compatible .NET DateTime
    using System;
    using System.Globalization;
    using System.Xml.Linq;
    
    /// <summary>
    /// RSS has a specific DateTime format - this method pulls out the DateTime from that provided
    /// </summary>
    /// <param name="Date">Incoming RSS DateTime</param>
    /// <returns>Compatible .NET DateTime</returns>
    public static DateTime ParseRssDate(string Date)
    {
        // clean up in the input date
        var newDate = Date;
        newDate = newDate.Replace("GMT", "+0:00");
        newDate = newDate.Replace("PST", "-8:00");
        newDate = newDate.Replace("PDT", "-7:00");
        newDate = newDate.Replace("MST", "-7:00");
        newDate = newDate.Replace("CST", "-6:00");
        newDate = newDate.Replace("CDT", "-5:00");
        newDate = newDate.Replace("EST", "-5:00");
        newDate = newDate.Replace("EDT", "-4:00");
        newDate = newDate.Replace("AST", "-4:00");
        newDate = newDate.Replace("ADT", "-3:00");
        // add your own here if I missed one you need
    
        // run the conversion
        var provider = CultureInfo.InvariantCulture;
        DateTime result;
        const string format = "ddd, dd MMM yyyy HH:mm:ss zzz";
    
        try
        {
            result = DateTime.ParseExact(newDate, format, provider);
        }
        catch (Exception)
        {
            //return the min value for that item. no need to have the entire feed fail
            result = DateTime.MinValue;
        }           
    
        // all done!
        return result;
    }
    • Public Snippets
    • Channels Snippets