コード例 #1
0
 public string GetProductUrl(string EAN)
 {
     string url = "https://www.knipex.com/en/search/?s=" + EAN;
     try
     {
         string unprocessedHtml = HtmlHandler.GetPageWithForm(url, EAN);
         HtmlDocument doc = new HtmlDocument();
         doc.LoadHtml(unprocessedHtml);
         string techInfo = doc.GetElementbyId("searchout").InnerHtml;
         doc.LoadHtml(techInfo);
         var result = doc.DocumentNode.SelectNodes("//a[@href]").First();
         var href = result.Attributes["href"].Value;
         href = HttpUtility.HtmlDecode(href);
         return "http://www.knipex.com" + href;
     }
     catch (Exception e)
     {
         Console.WriteLine("No product found " + EAN);
     }
     return null;
 }