Skip to content

Commit

Permalink
files
Browse files Browse the repository at this point in the history
  • Loading branch information
swistaczek committed Jun 14, 2011
1 parent 81d273e commit 3844362
Show file tree
Hide file tree
Showing 21 changed files with 1,155 additions and 0 deletions.
9 changes: 9 additions & 0 deletions czytnik-rss/.gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,9 @@
_ReSharper.*
bin
obj
build
dist
*.suo
*resharper*
*.user
~$*
35 changes: 35 additions & 0 deletions czytnik-rss/Backup/RssCrawler.Console/Program.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace RssCrawler.Console
{
class Program
{
static void Main(string[] args)
{
string[] feeds = new []
{
"http://feeds2.feedburner.com/CodeBetter",
"http://feeds2.feedburner.com/LosTechies",
"http://feeds2.feedburner.com/Devlicious"
};

string[] words = new []
{
"nhibernate",
"bdd"
};

System.Console.WriteLine("Beginning Processing Feeds");

Runner.FeedRunner runner = new Runner.FeedRunner();
runner.Crawl(feeds);


System.Console.ReadLine();
}
}
}
36 changes: 36 additions & 0 deletions czytnik-rss/Backup/RssCrawler.Console/Properties/AssemblyInfo.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RssCrawler.Console")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("RssCrawler.Console")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("93556318-e070-4b0b-aa59-98ed56b55659")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
65 changes: 65 additions & 0 deletions czytnik-rss/Backup/RssCrawler.Console/RssCrawler.Console.csproj
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RssCrawler.Console</RootNamespace>
<AssemblyName>RssCrawler.Console</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RssCrawler.Runner\RssCrawler.Runner.csproj">
<Project>{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}</Project>
<Name>RssCrawler.Runner</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
76 changes: 76 additions & 0 deletions czytnik-rss/Backup/RssCrawler.Runner/FeedRunner.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Xml;
using System.Xml.Linq;

namespace RssCrawler.Runner
{
public class FeedRunner
{
public int ArticleCount { get; set; }
private Mutex _mutex = new Mutex();

public void Crawl(string[] feeds)
{
foreach (var feed in feeds)
{
var feedFetcher = new FeedFetcher(feed, this);
Console.WriteLine("Starting Feed:{0}", feed);
Console.ReadLine();
new Thread(feedFetcher.ProcessFeed).Start();
}
}

public void UpdateCount()
{
lock(_mutex)
{
ArticleCount++;
}
}
}

public class Article
{
public string Title { get; set; }
public string Link { get; set; }
public string Description { get; set; }
}

public class FeedFetcher
{
private FeedRunner Runner { get; set; }
private readonly string _feedUrl;

public FeedFetcher(string feedUrl, FeedRunner runner)
{
Runner = runner;
_feedUrl = feedUrl;
}

public void ProcessFeed()
{
WebRequest request = WebRequest.Create(_feedUrl);
using (var response = request.GetResponse())
{
var xmlReader = XmlReader.Create(response.GetResponseStream());
XDocument document = XDocument.Load(xmlReader);

IEnumerable<Article> articles = document.Descendants("channel")
.Elements("item")
.Select(i => new Article { Title = i.Element("title").Value, Link = i.Element("link").Value});

foreach (var article in articles)
{
Runner.UpdateCount();
Console.WriteLine("#{0} Article:{1}", Runner.ArticleCount, article.Title);
}
}
}

}
}
36 changes: 36 additions & 0 deletions czytnik-rss/Backup/RssCrawler.Runner/Properties/AssemblyInfo.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RssCrawler.Runner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("RssCrawler.Runner")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1ffc2465-97af-4646-a7c5-a7ca5f08653a")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
59 changes: 59 additions & 0 deletions czytnik-rss/Backup/RssCrawler.Runner/RssCrawler.Runner.csproj
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RssCrawler.Runner</RootNamespace>
<AssemblyName>RssCrawler.Runner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FeedRunner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
26 changes: 26 additions & 0 deletions czytnik-rss/Backup/rss-crawler.sln
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssCrawler.Console", "RssCrawler.Console\RssCrawler.Console.csproj", "{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssCrawler.Runner", "RssCrawler.Runner\RssCrawler.Runner.csproj", "{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Release|Any CPU.Build.0 = Release|Any CPU
{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions czytnik-rss/README.markdown
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
Simple crawler that grabs feeds from multiple websites.
31 changes: 31 additions & 0 deletions czytnik-rss/RssCrawler.Console/Program.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

/* Prosty czytnik RSS - C# demo */
namespace RssCrawler.Console
{
class Program
{
static void Main(string[] args)
{
string[] feeds = new []
{
"http://rss.feedsportal.com/c/32739/f/530278/index.rss",
"http://gazeta.pl.feedsportal.com/c/32739/f/576250/index.rss",
"http://rss.gazeta.pl/pub/rss/kotek.xml"
};

System.Console.WriteLine("Rozpoczynam pobieranie źródeł ({0})", feeds.Length);
System.Console.WriteLine("Czekaj cierpliwie");
System.Console.WriteLine("----------------------------------------------------------------");

Runner.FeedRunner runner = new Runner.FeedRunner();
runner.Crawl(feeds);

System.Console.ReadLine();
}
}
}
Loading

0 comments on commit 3844362

Please sign in to comment.