/// <summary> /// Check the images associated with a sraigslit article in tineye to see if they are original or are 'stock' images from elsewhere on the web /// this is part of the dodginess check. If a stock image is used then it's dodgier /// </summary> /// <param name="craigsListItemId"></param> /// <param name="data"></param> /// <returns></returns> public async Task<List<TinEyeInfo>> GetTinEyePropertiesForImagesInArticleCollection(string craigsListItemId, string imagesCollection) { // // Convert the incoming text from the querystring into a collection objects and pass into the multithreaded getters // string[] images = imagesCollection.Split(new string[] { IMAGESEPERATOR }, StringSplitOptions.None); List<TinEyeInfo> tinEyeInfos = new List<TinEyeInfo>(); TinEyeInfo tinEyeInfo = new TinEyeInfo(); tinEyeInfo.CraigslistInfoId = craigsListItemId; foreach ( string image in images) { TinEyeImageInfo tinEyeImageInfo = new TinEyeImageInfo(); tinEyeImageInfo.ImageURI = TINEYE_IMAGE_URL_STUB + image; tinEyeImageInfo.TinEyeImageCount = DEFAULT_IMAGE_COUNT; tinEyeInfo.TinEyeImageInfos.Add(tinEyeImageInfo); } tinEyeInfos.Add(tinEyeInfo); MultithreadedTinEyeGetter tinEye = new MultithreadedTinEyeGetter(); return await tinEye.GetTinEyeInfo(tinEyeInfos); //return "not yet implemented"; }
/// <summary> /// The actions from the foreach loop are moved to this async method. /// </summary> /// <param name="url"></param> /// <param name="client"></param> /// <returns></returns> async Task<TinEyeImageInfo> ProcessListing(TinEyeImageInfo tinEyeImageInfo, HttpClient client) { StringContent postData = new StringContent(String.Format("url={0}",tinEyeImageInfo.ImageURI), Encoding.UTF8, "application/x-www-form-urlencoded"); var result = await client.PostAsync("http://tineye.com/search", postData); if (result.IsSuccessStatusCode) { // // Parse the HTML and extract the image count and us it to update the tinEyeImageInfo.TinEyeImageCount property // // Geno to here : just started debugging this tin eye stuff to get it working boradly // will then need to get the regexs right to pull out the tineye count // something like : // its in their page in the format : <h2><span>0</span> Results</h2> // HtmlAgilityPack.HtmlNodeCollection itemNodes = htmlDoc.DocumentNode.SelectNodes("/h2/span[1]']"); // only I scrapped the HTMlAgailitypack in this calss as having trouble matching it's input types and the return tpye of the POST I am making // string x = await result.Content.ReadAsStringAsync(); } return tinEyeImageInfo; }