示例#1
0
        static List <Movie> SearchMovieByTitle(string title)
        {
            string             url     = $"https://subscene.com/subtitles/searchbytitle?query={title}";
            var                doc     = GetHtmlDocument(url);
            HtmlNodeCollection nodes   = doc.DocumentNode.SelectNodes("//*[@id=\"left\"]/div/div");
            var                movies  = new List <Movie>();
            int                counter = 0;

            foreach (var ul in nodes.Elements("ul"))
            {
                foreach (var li in ul.Elements("li"))
                {
                    movies.Add(new Movie()
                    {
                        Id    = counter,
                        Title = li.Elements("div").ElementAt(0).InnerText.CleanString(),
                        Url   = li.Elements("div").ElementAt(0).Element("a").Attributes["href"].Value.CleanString()
                    });

                    counter++;
                }
            }

            return(movies);
        }
示例#2
0
 public IEnumerable <HtmlNode> GetTrNodes(HtmlDocument htmlDocument, string tableXpath)
 {
     if (htmlDocument != null && htmlDocument.DocumentNode != null && htmlDocument.DocumentNode.HasChildNodes)
     {
         HtmlNodeCollection nodes = htmlDocument.DocumentNode.SelectNodes(tableXpath);
         if (nodes != null)
         {
             return(nodes.Elements("tr"));
         }
     }
     return(new List <HtmlNode>());
 }
示例#3
0
        //일반 상품 상세
        static async Task GetProductItemViewBox(string productCode)
        {
            using (var handler = new HttpClientHandler()
            {
                CookieContainer = container
            })
                using (var client = new HttpClient(handler))
                {
                    client.BaseAddress = new Uri("https://www.ssgdfm.com");

                    var content = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("siteNatnCode", "KR"),
                        new KeyValuePair <string, string>("optnSelected", "N"),
                        new KeyValuePair <string, string>("saleStoreCode", "06"),
                        new KeyValuePair <string, string>("prdtCode", productCode) // 01279000023 판매중상품 위시리스트  일반상품 41009000349
                    });
                    var result = await client.PostAsync("/shop/product/ajax/getProductItemViewBox", content);


                    string resultContent = await result.Content.ReadAsStringAsync();

                    HtmlAgilityPack.HtmlDocument mydoc = new HtmlAgilityPack.HtmlDocument();
                    mydoc.LoadHtml(resultContent);

                    HtmlNodeCollection nodeCollection = mydoc.DocumentNode.SelectNodes("//div[@class='info-product']//form//div[@class='button-group']//a[@class='btn-productDetail btn-buy']");

                    string saleYN = "N";

                    if (nodeCollection != null)
                    {
                        string btnName = nodeCollection.Elements().ElementAt(0).InnerHtml;

                        if (btnName == "바로구매")
                        {
                            saleYN = "Y";
                        }
                    }

                    if (saleYN == "Y")
                    {
                        //ORDER START
                    }
                }
        }
示例#4
0
        //브랜드샵 상품
        static async Task GetBrandShopViewItem(string url, string productCode)
        {
            using (var handler = new HttpClientHandler()
            {
                CookieContainer = container
            })
                using (var client = new HttpClient(handler))
                {
                    client.BaseAddress = new Uri("https://www.ssgdfm.com");

                    var content = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("isRedirect", "Y"),
                        new KeyValuePair <string, string>("prdtCode", productCode) // 01279000023 판매중상품 위시리스트  일반상품 41009000349
                    });
                    var result = await client.PostAsync(url, content);


                    string resultContent = await result.Content.ReadAsStringAsync();

                    HtmlAgilityPack.HtmlDocument mydoc = new HtmlAgilityPack.HtmlDocument();
                    mydoc.LoadHtml(resultContent);

                    HtmlNodeCollection nodeCollection = mydoc.DocumentNode.SelectNodes("//div[@class='priceInfo']//ul[@class='buy_btn']//li[@class='btn_list']//a");

                    string saleYN = "N";

                    if (nodeCollection != null)
                    {
                        string btnName = nodeCollection.Elements().ElementAt(0).InnerHtml;

                        if (btnName == "바로구매")
                        {
                            saleYN = "Y";
                        }
                    }

                    if (saleYN == "Y")
                    {
                        //ORDER START
                    }
                }
        }
示例#5
0
        /// <summary>
        /// Gets the IMDb title
        /// </summary>
        /// <param name="session">a session instance.</param>
        /// <param name="imdbID">IMDb ID</param>
        /// <returns></returns>
        public static TitleDetails GetTitle(Session session, string imdbID)
        {
            string uri = string.Format(session.Settings.BaseUriMobile, session.Settings.TitleDetailsMobile, "/" + imdbID + "/");

            HtmlNode root = GetResponseFromSite(session, uri);

            TitleDetails title = new TitleDetails();

            title.session = session;
            title.ID      = imdbID;

            // Main Details
            HtmlNode node      = root.SelectSingleNode("//div[@class='media-body']");
            string   titleInfo = node.SelectSingleNode("h1").InnerText;

            ParseDisplayStringToTitleBase(title, HttpUtility.HtmlDecode(titleInfo));

            // Tagline
            node = node.SelectSingleNode("p");
            if (node != null)
            {
                title.Tagline = HttpUtility.HtmlDecode(node.InnerText);
            }

            // Release date
            node = root.SelectSingleNode("//section[h3='Release Date:']/span");
            if (node != null)
            {
                DateTime value;
                if (DateTime.TryParse(node.InnerText, out value))
                {
                    title.ReleaseDate = value;
                }
            }

            // Summary
            node = root.SelectSingleNode("//p[@itemprop='description']");
            if (node != null)
            {
                node = node.FirstChild;
                if (node != null)
                {
                    title.Plot = HttpUtility.HtmlDecode(node.InnerText).Trim();
                }
            }

            // Genres
            title.Genres = root.SelectNodes("//span[@itemprop='genre']").Select(s => HttpUtility.HtmlDecode(s.InnerText)).ToList();


            // Ratings / Votes
            // todo: fix this
            node = root.SelectSingleNode("//p[@class='votes']/strong");
            if (node != null)
            {
                title.Rating = Convert.ToDouble(node.InnerText, CultureInfo.InvariantCulture.NumberFormat);

                // Votes
                string votes = node.NextSibling.InnerText;
                if (votes.Contains("votes"))
                {
                    votes       = Regex.Replace(votes, @".+?([\d\,]+) votes.+", "$1", RegexOptions.Singleline);
                    title.Votes = Convert.ToInt32(votes.Replace(",", ""));
                }
            }

            // Certification
            node = root.SelectSingleNode("//span[@itemprop='contentRating']");
            if (node != null)
            {
                title.Certificate = HttpUtility.HtmlDecode(node.GetAttributeValue("content", "?"));
            }

            //Poster
            node = root.SelectSingleNode("//div[@class='poster']/a");
            if (node != null)
            {
                Match match = imdbImageExpression.Match(node.Attributes["href"].Value);
                if (match.Success)
                {
                    title.Image = HttpUtility.UrlDecode(match.Groups["filename"].Value + match.Groups["ext"].Value);
                }
            }

            // Cast
            HtmlNodeCollection nodes = root.SelectNodes("//div[@id='cast-and-crew']/div/ul/li");

            if (nodes != null)
            {
                foreach (HtmlNode n in nodes)
                {
                    HtmlNode infoNode = n.SelectSingleNode("div[@class='text-center']/div[@class='ellipse']");
                    if (infoNode == null)
                    {
                        continue;
                    }

                    // Character info
                    Character character = new Character();
                    character.Actor         = new NameReference();
                    character.Actor.session = session;
                    character.Actor.Name    = HttpUtility.HtmlDecode(infoNode.InnerText).Trim();

                    infoNode = n.SelectSingleNode("a");
                    if (infoNode != null)
                    {
                        character.Actor.ID = infoNode.Attributes["href"].Value.Replace("http://m.imdb.com/name/", "").Replace("/", "");
                    }

                    infoNode = n.Descendants("small").Last();
                    if (infoNode != null)
                    {
                        character.Name = HttpUtility.HtmlDecode(infoNode.InnerText).Trim();
                    }

                    infoNode = n.SelectSingleNode("a/img");
                    if (infoNode != null)
                    {
                        Match match = imdbImageExpression.Match(infoNode.Attributes["src"].Value);
                        if (match.Success)
                        {
                            character.Actor.Image = HttpUtility.UrlDecode(match.Groups["filename"].Value + match.Groups["ext"].Value);
                        }
                    }

                    // add character object to the title
                    title.Cast.Add(character);
                }
            }

            nodes = root.SelectNodes("//div[@id='cast-and-crew']");
            if (nodes != null)
            {
                foreach (HtmlNode n in nodes.Elements("a"))
                {
                    var itemprop = n.GetAttributeValue("itemprop", "");
                    if (itemprop == "director" || itemprop == "creator")
                    {
                        NameReference person = new NameReference();
                        person.session = session;
                        person.ID      = n.Attributes["href"].Value.Replace("//m.imdb.com/name/", "").Replace("/", "");
                        person.ID      = person.ID.Substring(0, person.ID.IndexOf("?"));
                        person.Name    = HttpUtility.HtmlDecode(n.Descendants("span").First().InnerText).Trim();

                        if (itemprop == "director")
                        {
                            title.Directors.Add(person);
                        }
                        else if (itemprop == "creator")
                        {
                            title.Writers.Add(person);
                        }
                    }
                }
            }

            HtmlNode trailerNode = root.SelectSingleNode("//span[@data-trailer-id]");

            if (trailerNode != null)
            {
                string videoId = trailerNode.GetAttributeValue("data-trailer-id", string.Empty);
                if (videoId != string.Empty)
                {
                    title.trailer = videoId;
                }
            }

            return(title);
        }
示例#6
0
        public ArrayList GetDataSunat(string Ruc)
        {
            Bitmap Imagen = DevuelveImagenCatcha();
            var    Capcha = GetTextFromImage(Imagen);

            String         UrlSunat    = String.Format("http://www.sunat.gob.pe/cl-ti-itmrconsruc/jcrS00Alias?accion=consPorRuc&nroRuc={0}&codigo={1}&tipdoc=1", Ruc, Capcha);
            HttpWebRequest enlaceSunat = (HttpWebRequest)WebRequest.Create(UrlSunat);

            enlaceSunat.CookieContainer          = this.cokkie;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
            enlaceSunat.Credentials = CredentialCache.DefaultCredentials;
            WebResponse  respuesta_web  = enlaceSunat.GetResponse();
            Stream       myStream       = respuesta_web.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myStream);
            Int32        Adicionar      = 0;

            if (Ruc.Substring(0, 1) == "1")
            {
                Adicionar = 4;
            }

            string    RazonSocial      = "";
            string    ConsultaCliente  = "";
            string    RUCN             = "";
            string    Estado           = "";
            string    FechaInicio      = "";
            string    FechaInscripcion = "";
            string    FechaBaja        = "";
            string    Direccion        = "";
            string    NoEncontrado     = "";
            ArrayList Valores          = new ArrayList();


            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(myStreamReader.ReadToEnd());

            HtmlNodeCollection NodeTable = document.DocumentNode.SelectNodes("//table");

            if (NodeTable != null)
            {
                var listNodeTr = NodeTable.Elements("tr").ToArray();
                if (listNodeTr != null)
                {
                    var nodeNoEncontrado = listNodeTr[2].Elements("td").ToArray();
                    if (nodeNoEncontrado != null)
                    {
                        NoEncontrado = nodeNoEncontrado[0].InnerHtml.Trim();
                        Valores.Insert(0, NoEncontrado);
                        if (NoEncontrado.ToString().Contains(Ruc))
                        {
                            Valores.Insert(1, "");
                            Valores.Insert(2, "");
                            Valores.Insert(3, "");
                            Valores.Insert(4, "");
                            Valores.Insert(5, "");
                            Valores.Insert(6, "");
                            return(Valores);
                        }
                    }
                    var nodeRazonSocial = listNodeTr[0].Elements("td").ToArray();
                    if (nodeRazonSocial != null)
                    {
                        RazonSocial     = nodeRazonSocial[1].InnerHtml.Trim();
                        ConsultaCliente = nodeRazonSocial[1].InnerHtml.Trim();
                        RUCN            = ConsultaCliente.Substring(0, 11).Trim();
                        ConsultaCliente = ConsultaCliente.Substring(13, ConsultaCliente.Length - 13).Trim();
                        Valores.Insert(1, ConsultaCliente);
                    }
                    var nodefechaInicio = listNodeTr[3].Elements("td").ToArray();
                    if (nodefechaInicio != null)
                    {
                        FechaInscripcion = nodefechaInicio[1].InnerHtml.Trim();
                        Valores.Insert(2, FechaInscripcion);
                        if (nodefechaInicio.Count() >= 3)
                        {
                            FechaInicio = nodefechaInicio[3].InnerHtml.Trim();
                            Valores.Insert(3, FechaInicio);
                        }
                        else
                        {
                            FechaInicio = "";
                            Valores.Insert(3, FechaInicio);
                        }
                    }
                    var nodeEstado = listNodeTr[4].Elements("td").ToArray();
                    if (nodeEstado != null)
                    {
                        Estado = nodeEstado[1].InnerHtml.Trim();
                        Valores.Insert(4, Estado);
                        if (nodeEstado.Count() >= 3)
                        {
                            FechaBaja = nodeEstado[2].InnerHtml.Trim();
                            Valores.Insert(5, FechaBaja);
                        }
                        else
                        {
                            FechaBaja = "";
                            Valores.Insert(5, FechaBaja);
                        }
                    }
                    var nodeDireccion = listNodeTr[6].Elements("td").ToArray();
                    if (nodefechaInicio != null)
                    {
                        if (Ruc.Substring(0, 1) == "1")
                        {
                            Direccion = "";
                        }
                        else
                        {
                            Direccion = nodeDireccion[1].InnerHtml.Trim().Replace("  ", "");
                        }
                        Valores.Insert(6, Direccion);
                    }
                }
            }
            return(Valores);
        }