Example #1
0
		public override Post[] CheckForNewImages (bool firstCheck = false)
		{
			List<Post> posts = new List<Post> ();
			bool readNextPage = true;
			string id = "";
			int count = 0;
			string html;

			html = NetHelper.DownloadHTML (this.URL);
			if (html == null) {
				DebugMessage ("Could not download HTML");
				return null;
			}

			Match mtch = Regex.Match (html, regexNextPage, RegexOptions.Multiline | RegexOptions.IgnoreCase);
			if (!mtch.Success) {
				DebugMessage ("Could not find ID");
				return null;
			}
			else
				id = mtch.Groups["id"].Value;

			do {
				if (html == null) {
					DebugMessage ("Could not download HTML");
					return null;
				}

				MatchCollection mtchs = Regex.Matches (html, regexPosts, RegexOptions.Multiline | RegexOptions.IgnoreCase);
				if(mtchs.Count > 0) {
					foreach(Match mtchp in mtchs) {
						Post pst = new Post(this,
						                    mtchp.Groups["title"].Value,
						                    NetHelper.DownloadBitmap(mtchp.Groups["imageLink"].Value),
						                    "http://www.9gag.com/gag/" + mtchp.Groups["link"].Value);
						if(!pst.Equals(this.LastPost)) {
							posts.Add (pst);
						} else {
							readNextPage = false;
							break;
						}
					}
				} else {
					readNextPage = false;
				}

				if(firstCheck)
					break;

				count += 10;
				html = NetHelper.DownloadHTML (this.URL + "?id=" + id + "&c=" + count.ToString ());
			} while(readNextPage);
			if(posts.Count > 0)
				LastPost = posts[0];
			return posts.ToArray();
		}
Example #2
0
 public PostsFoundEventArgs(Post[] posts, WebSite site)
 {
     this.posts = posts;
     this.site = site;
 }
Example #3
0
File: Post.cs Project: BigMo/webimg
 public bool Equals(Post pst)
 {
     if(pst == null)
         return false;
     return pst.Bitmap.Equals (this.bmp) &&
             pst.Date.Equals (this.date) &&
             pst.Description.Equals(this.description) &&
             pst.Headline.Equals(this.Headline) &&
             pst.URL.Equals(this.url);
 }