Exemplo n.º 1
0
    public List <AuctionObject> htmlParser(string html, JObject selectors, [Optional] string baseURL)
    {
        string auctionTitleSelctor = (string)selectors["auctionTitles"];
        string auctionLinkSelctor  = (string)selectors["auctionLinks"];
        var    auctionNumberRegex  = new Regex(@"(?<=ccoa)\d+");
        var    auctionList         = new List <AuctionObject>();
        var    htmlDoc             = new HtmlDocument();

        htmlDoc.LoadHtml(html);
        var auctionTitles = htmlDoc.DocumentNode.SelectNodes(auctionTitleSelctor);
        var auctionLinks  = htmlDoc.DocumentNode.SelectNodes(auctionLinkSelctor);
        int totalLinks    = htmlDoc.DocumentNode.SelectNodes(auctionTitleSelctor).Count;

        for (int i = 0; i < totalLinks; i++)
        {
            AuctionObject auction = new AuctionObject
            {
                Title = auctionTitles[i].InnerHtml,
                Link  = (string)(baseURL + auctionLinks[i].Attributes["href"].Value)
            };
            auction.AuctionNumber = auctionNumberRegex.Match(auction.Link).ToString();
            auctionList.Add(auction);
        }
        return(auctionList);
    }
Exemplo n.º 2
0
 void Remove(AuctionObject o)
 {
     for (int i = 0; i < negotiators.Length; i++)
     {
         if (negotiators[i].purchased && negotiators[i].purchased == o)
         {
             negotiators[i].purchased = null;
             return;
         }
     }
 }