Hey there. I am trying to do a little bit of data extraction on a few websites for my personal usage (no it's not some kind of spam bot) and I managed to extract data from one website but when trying to connect to another website I get error messages I don't really understand. Any help ?
And here is the error message:Code:public abstract class DataFetcher { public List<Serie> Contents; public List<KeyValuePair<Serie, int>> Followed; protected string SourceCode; protected string Identifier; public void FetchSourceCode(string url) { StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; Logger.ToLog("Requesting '" + url + "'"); HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse) request.GetResponse(); Stream resStream = response.GetResponseStream(); string tempString = null; int count = 0; Console.WriteLine("Attempting to read webpage ..."); bool read = false; do { count = resStream.Read(buf, 0, buf.Length); if (count != 0) { if(read == false) { read = true; Console.WriteLine("Reading..."); } tempString = Encoding.ASCII.GetString(buf, 0, count); sb.Append(tempString); } } while (count > 0); SourceCode = sb.ToString(); } public void GetContentsFromFile(string path = "") { // irrelevant } public void LogContents() { StreamWriter w = new StreamWriter(Identifier + ".txt"); foreach (Serie i in Contents) { w.WriteLine(i.Name + ';' + i.Quantity.ToString() + ';' + i.URL + ';' + (i.Follow == false ? '0' : '1')); } } public DataFetcher() { SourceCode = ""; Contents = new List<Serie>(); Followed = new List<KeyValuePair<Serie, int>>(); } protected abstract bool NextSerie(string contents, ref int lastIndexUsed); public abstract List<Serie> GetContents(string source = ""); public abstract List<KeyValuePair<Serie, int>> CheckNewEpisodesFollowed(); } public class DF_DPS : DataFetcher { protected override bool NextSerie(string contents, ref int lastIndexUsed) { // irrelevant } public override List<Serie> GetContents(string source) { if(SourceCode == "") FetchSourceCode("http://www.dpstream.net/serie.html"); int workingIndex = SourceCode.IndexOf("rsm2"); while(NextSerie(SourceCode, ref workingIndex) == true); return Contents; } public override List<KeyValuePair<Serie, int>> CheckNewEpisodesFollowed() { return null; } public DF_DPS() { Identifier = "DPStream"; } }My logger indicates that the url provided is fine and since I use the same method to connect (it is implemented through the base class) I pretty much don't know where to look for my mistake.System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Bool ean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at DataFetcher.FetchSourceCode(String url) in c:\Users\win7\Documents\SharpDevelop Projects\net\net\Program.cs:line 55
at DF_DPS.GetContents(String source) in c:\Users\win7\Documents\SharpDevelop Projects\net\net\Program.cs:line 212
at WebFetch.Main(String[] args) in c:\Users\win7\Documents\SharpDevelop Projects\net\net\Program.cs:line 232
Thanks.
Edit: Also any general comment on my C# style is welcome. I literally just started out with the language specification document and a lot of googling.