static void AddKeysToProduct(ProductInfo product, WebClient wc) { // Get keys string keysPage = wc.DownloadString(string.Format("http://www.desura.com/games/{0}/keys", product.Slug)); CQ csqKeys = keysPage; CQ kSearch = csqKeys ["span.price:contains(Select),span.price:contains(Get)"]; foreach (var kSpanE in kSearch) { CQ kSpan = kSpanE.Cq(); CQ parentSpan = kSpan.Closest("span.buy.clear"); // Get key name string keyType = kSpan.Parent().Find(".action").Text(); CQ infoBlock = parentSpan.Find(".buycontent .heading.clear"); string keyName = infoBlock.Children().Eq(0).Text(); string name = string.Format("{0} ({1})", keyName, keyType); // Get key string key = kSpan.Text() == "Select" ? parentSpan.Find(".summary [name=\"key\"]").Attr("value") : string.Format("Reveal key at http://www.desura.com/games/{0}/keys", product.Slug); product.Keys.Add(new NameKeyStringTuple(name, key)); } }
static List <Tuple <string, string, string> > GetDownloads(string slug, int branchId, WebClient wc) { List <Tuple <string, string, string> > downloads = new List <Tuple <string, string, string> > (); // Get downloads string downloadsPage = wc.DownloadString(string.Format("http://www.desura.com/games/{0}/download/{1}", slug, branchId)); CQ csqDownload = downloadsPage; CQ dSearch = csqDownload ["span.action:contains(Download)"]; foreach (var dSpanE in dSearch) { CQ dSpan = dSpanE.Cq(); CQ parentA = dSpan.Closest("a"); // Get download link string link = "http://www.desura.com" + parentA.Attr("href"); // Get download name CQ infoBlock = parentA.Find(".buycontent .heading.clear"); downloads.Add(new Tuple <string, string, string> (infoBlock.Children().Eq(0).Text(), infoBlock.Children().Eq(1).Text(), link)); } return(downloads); }