Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. //download matches page
  2. string matches = client.DownloadString("/match?timekey=1&matchOrderBy=SPECIAL_BLEND&use_prefs=1&discard_prefs=1&count=30");
  3.  
  4. // convert to HTML document
  5. HtmlDocument matchesHtmlDoc = new HtmlDocument();
  6. matchesHtmlDoc.LoadHtml(matches);
  7.  
  8. //get the xpath for the div of girls
  9. string matchesXpath = String.Format("//div[@id='{0}']/div", Constants.matchResultDivId);
  10.  
  11. //select the match nodes and put it into a "people" node collection
  12. HtmlNodeCollection people = matchesHtmlDoc
  13.     .DocumentNode
  14.     .SelectNodes(matchesXpath);
  15.  
  16. //loop through the girls and process them, skipping girls already seen
  17. foreach (HtmlNode person in people)
  18. {
  19.     string matchCardXpath = String.Format("./div[contains(@class,'{0}')]", Constants.matchCardClass);
  20.     string matchCardTextXpath = String.Format("{0}/div[@class='{1}']", matchCardXpath, Constants.matchCardText);
  21.     string profileInfoXpath = String.Format("{0}/div[@class='profile_info']", matchCardTextXpath);
  22.     string userInfoXpath = String.Format("{0}/div[@class='userinfo']", profileInfoXpath);
  23.  
  24.     // find person info, including name and link to picture
  25.     string personLinkXpath = String.Format("{0}/a", matchCardXpath);
  26.     HtmlNode personLinkNode = person.SelectSingleNode(personLinkXpath);
  27.  
  28.     string userName = personLinkNode.Attributes["data-username"].Value;
  29.  
  30.     //check if username is already in excel/DB or already processed and stored in the running list
  31.     if (processedGirls.Contains(userName) || listOfGirls.Where(p => p.Username.Contains(userName)).FirstOrDefault() != null)
  32.     {
  33.         Console.WriteLine("{0} :: {1} :: Processed her... Skipping.",DateTime.Now.ToShortTimeString() ,userName);
  34.         continue;  //don't process her again
  35.     }
  36.  
  37.     girlsProcessed++;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement