Esempio n. 1
0
        public static List <ProductInfo> getProductHome(string url = "http://buyee.jp/rakuten/?lang=ja")
        {
            List <ProductInfo> list = new List <ProductInfo>();
            var dom  = CQ.CreateFromUrl(url);
            CQ  divs = dom.Select("#content_inner .rcmd_product_whole");

            foreach (var item in divs.ToList())
            {
                string name     = CQ.Create(item)["div.rcmd_product_title a"].Select(x => x.Cq().Text()).FirstOrDefault().ToString().Trim();
                string itemcode = CQ.Create(item)["div.rcmd_product_title a"].Select(x => x.Cq().Attr("href")).FirstOrDefault().ToString().Trim();
                itemcode = itemcode.Substring(itemcode.LastIndexOf('/') + 1);
                string image = CQ.Create(item)["img.rcmd_product_image"].Select(x => x.Cq().Attr("src")).FirstOrDefault().ToString().Trim();
                string pri   = CQ.Create(item)["div.rcmd_product_price"].Select(x => x.Cq().Text()).FirstOrDefault().ToString().Trim();
                pri = Regex.Matches(pri, @"[0-9]*[\.,]?[0-9]+")[0].Value;
                ProductInfo pro = new ProductInfo()
                {
                    image    = image,
                    name     = name,
                    price    = Convert.ToDouble(pri),
                    itemCode = WebUtility.HtmlDecode(itemcode).Replace("%3A", "-")
                };
                list.Add(pro);
            }
            return(list);
        }
Esempio n. 2
0
        private void loadVietNamChart()
        {
            string playlistID = "87";

            deleteTrackInPlaylist(playlistID);
            string url = "https://chiasenhac.vn/nhac-hot/vietnam.html";
            CQ     dom = CQ.CreateFromUrl(url);

            for (int i = 1; i < 21; i++)
            {
                Monitor.Enter(locker);
                try
                {
                    VietNamChart_worker.ReportProgress((int)((++progress * 1.0f / totalProgress) * 100));
                }
                catch (System.Exception)
                {
                }
                finally
                {
                    Monitor.Exit(locker);
                }
                string realUrl = dom[@"div.music_recommendation div.d-table div[id*='music-listen']:nth-of-type(" + i + ") div.tool ul li:nth-of-type(1) a"].Attr("href");
                string trackID;
                if (Database.checkTrackExisted(realUrl))
                {
                    trackID = Database.getTrackIdBaseOnTrackLink(realUrl);
                }
                else
                {
                    trackID = Database.addTrackToDatabase(realUrl);
                }
                Database.AddTrackToPlaylist(trackID, playlistID);
            }
        }
Esempio n. 3
0
        public void busca(string text)
        {
            tableLayoutPanel1.Invoke(new Action(() => tableLayoutPanel1.Controls.Clear()));

            try
            {
                text = text.Trim();
                text = text.Replace(" ", "-");
                text = text.ToLower();

                var dom = CQ.CreateFromUrl("http://mp3freex.org/" + text + "-download");


                var selectionHtml = dom.Select(".actl");

                foreach (var item in selectionHtml)
                {
                    var cancion = CQ.Create(item);
                    var title   = cancion.Select(".res_title").Text();
                    var link    = "http://mp3freex.org/download-mp3/" + cancion.Select("#dowload").Select(".mp3download").Attr("data-online");

                    tableLayoutPanel1.Invoke(new Action(() => tableLayoutPanel1.Controls.Add(new itemLista(new Cancion(title, link)))));
                }
            }
            catch (Exception e) {
            }
        }
Esempio n. 4
0
 public override int GetPrice()
 {
     try
     {
         CQ dom       = CQ.CreateFromUrl(this.link);
         CQ priceNode = dom[".fl-pdp-price__current"];
         if (priceNode.Length > 0)
         {
             string          s       = "";
             MatchCollection matches = Regex.Matches(priceNode.Text(), @"[\d]+");
             foreach (Match m in matches)
             {
                 s += m.Value;
             }
             if (s != "")
             {
                 return(Convert.ToInt32(s));
             }
             else
             {
                 return(-1);
             }
         }
         return(-1);
     }
     catch (Exception e)
     {
         CConsole.GetInstance().LogError(e.Message);
         return(-1);
     }
 }
        public override int GetPrice()
        {
            try
            {
                CQ Dom       = CQ.CreateFromUrl(this.link);
                CQ priceNode = Dom["meta[itemprop='price']"];
                if (priceNode.Length > 0)
                {
                    string s = priceNode.Attr("content");
                    if (s != "")
                    {
                        return(Convert.ToInt32(s));
                    }
                    else
                    {
                        return(-1);
                    }
                }

                return(-1);
            }
            catch (Exception e)
            {
                CConsole.GetInstance().LogError(e.Message);
                return(-1);
            }
        }
Esempio n. 6
0
        private dynamic QueryBook1(string fileName)
        {
            var    url = "https://www.douban.com/search?q=" + fileName;
            CQ     dom = CQ.CreateFromUrl(url).Render();
            var    span_book = dom["span"].FirstOrDefault(s => s.TextContent == "[书籍]");
            String bookName = "", rating = "", detailUrl = "", tags = "";

            try
            {
                bookName  = span_book.NextElementSibling.InnerText;
                detailUrl = span_book.NextElementSibling.Attributes["href"];
            }
            catch { }

            try
            {
                rating = span_book.ParentNode.NextElementSibling.ChildElements.First(a => a.ClassName == "rating_nums").TextContent;
            }
            catch { }

            if (!String.IsNullOrEmpty(detailUrl))
            {
                //detail page
                CQ domDetail = CQ.CreateFromUrl(detailUrl).Render();
                tags = String.Join(",", _commonTags.Union(domDetail[".  tag"].Contents().Select(c => c.ToString())));
            }

            dynamic content = new { BookName = bookName, Rating = rating, Tags = tags, IsMatched = bookName.Trim().Equals(fileName.Trim()) };

            return(content);
        }
        private void GetLastFmCurrentSong()
        {
            CQ dom = CQ.CreateFromUrl("http://www.last.fm/user/" + ApplicationSettings.Default.Username + "");

            string listeningNow = dom["#recentTracks:first .dateCell:first"].Text();

            string track;

            if (listeningNow.Contains("Listening now"))
            {
                track = dom["#recentTracks:first .subjectCell:first"].Text();
                track = track.Substring(2, track.Length - 3);
            }
            else
            {
                track = "Not listening anything";
            }

            System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\song.txt", track);

            _currentDispatcher.Invoke(() =>
            {
                SongNameTextBox = track;
            });
        }
        public static ProductInfo getDetail(int page = 1, int category = 110729, string sort = "standard", string translationType = "", string query = "", string categoryName = "", string productId = "")
        {
            ProductInfo pro  = new ProductInfo();
            string      url  = "http://buyee.jp/item/yahoo/auction/" + productId + "?lang=ja";
            var         item = CQ.CreateFromUrl(url).Select("#content").FirstOrDefault();

            pro.name = CQ.Create(item)["#itemHeader h1"].Select(x => x.Cq().Text()).FirstOrDefault().ToString().Trim();
            string pri = CQ.Create(item)[".current_price_output em"].Select(x => x.Cq().Text()).FirstOrDefault().ToString().Trim();

            pri          = Regex.Matches(pri, @"[0-9]*[\.,]?[0-9]+")[0].Value;
            pro.price    = Convert.ToDouble(pri);
            pro.cateName = categoryName;
            pro.image    = CQ.Create(item)["ul.slides li a img:first"].Select(x => x.Cq().Attr("src")).FirstOrDefault().ToString().Trim();
            //pro.description = CQ.Create(item)["#shopping_item_detail_container"].Select(x => x.Cq().Document.InnerHTML).FirstOrDefault().ToString().Trim();
            var           dom       = CQ.CreateFromUrl(url);
            CQ            divs      = dom.Select("#itemPhoto_sec li");
            List <string> strImages = new List <string>();

            foreach (var img in divs.ToList())
            {
                string image = CQ.Create(img)["img"].Select(x => x.Cq().Attr("src")).FirstOrDefault().ToString().Trim();
                strImages.Add(image);
            }
            pro.images      = strImages;
            pro.summary     = CQ.Create(item)["#itemDetail_sec"].Select(x => x.Cq().Html()).FirstOrDefault().ToString().Trim();
            pro.auction     = "<dl>" + CQ.Create(item)[".current_price"].Select(x => x.Cq().Html()).FirstOrDefault().ToString().Trim() + "</dl>";
            pro.auctionInfo = "<dl>" + CQ.Create(item)[".no_border"].Select(x => x.Cq().Html()).FirstOrDefault().ToString().Trim() + "</dl>";
            //pro.checkAvailable =CQ.Create(item)["#item_inventories"].Select(x => x.Cq().Html()).FirstOrDefault().ToString().Trim().Replace("generalicon-checkmark", "glyphicon glyphicon-ok").Replace("generalicon-remove", "glyphicon glyphicon-remove") ;
            //pro.attribute ="<dl class='attr'>"+ CQ.Create(item)["dl.shopping_input_container"].Select(x => x.Cq().Html()).FirstOrDefault().ToString().Trim()+"</dl>";
            return(pro);
        }
Esempio n. 9
0
File: Form1.cs Progetto: AlexFell/1
        private void button2_Click(object sender, EventArgs e)
        {
            int chet = 0;

            this.Controls.Remove(button1);
            this.Controls.Remove(button2);
            this.Controls.Remove(button3);
            this.Controls.Remove(label1);
            this.Controls.Add(button4);
            this.Controls.Add(label2);
            holidays = DateTime.Now.AddDays(1).ToShortDateString();
            holiday  = holidays.Split('.');
            string month = Month(holiday[1], holiday[0]);

            url = "https://ru.wikipedia.org/wiki/" + holiday[0] + "_" + month;

            CQ dom = CQ.CreateFromUrl(url);

            foreach (IDomObject obj in dom.Find("span.mw-headline"))
            {
                if (obj.TextContent == "Международные" || obj.TextContent == "Национальные" || obj.TextContent == "Профессиональные")
                {
                    label2.Text += obj.TextContent += ":\n";
                    foreach (IDomObject obi in dom.Find(".mw-parser-output>ul").Eq(chet))
                    {
                        if (obi.TextContent != "")
                        {
                            label2.Text += obi.TextContent += "\n";
                        }
                    }
                    label2.Text += "\n";
                    chet++;
                }
            }
        }
Esempio n. 10
0
        //[Test, TestMethod]
        public void YahooFinanceExample()
        {
            string URL = "http://finance.yahoo.com/q/op?s=MSFT&m=2012-09";

            CQ doc = CQ.CreateFromUrl(URL);

            // the two tables have a class "yfnc_datamodoutline1", but wrap an inner table

            var rows = doc.Select(".yfnc_datamodoutline1 table tr");

            //  in CsQuery the indexer [] is sysnoymous with Select method
            //   Each th header row has the class ".yfnc_tablehead1" - figure out which columsn to use
            //   for the four parts you are interested in

            var headers     = rows.First().Find(".yfnc_tablehead1");
            int strikeIndex = headers.Filter(":contains('Strike')").Index();
            int symbolIndex = headers.Filter(":contains('Symbol')").Index();
            int bidIndex    = headers.Filter(":contains('Bid')").Index();
            int askIndex    = headers.Filter(":contains('Ask')").Index();

            //  iterate over all rows, except the header one (the "has" excludes the header row)

            foreach (var row in rows.Has("td"))
            {
                CQ cells = row.Cq().Find("td");

                string output = String.Format("Strike: {0} Symbol: {1} Bid: {2} ask: {3}",
                                              cells[strikeIndex].Cq().Text(),
                                              cells[symbolIndex].Cq().Text(),
                                              cells[bidIndex].Cq().Text(),
                                              cells[askIndex].Cq().Text());

                Console.WriteLine(output);
            }
        }
Esempio n. 11
0
        static public string getTrackTitle(string url)
        {
            CQ     css       = CQ.CreateFromUrl(url);
            string trackName = css[@"div[class='col-md-4'] div[class='card-body'] h2"].Text();

            return(trackName);
        }
Esempio n. 12
0
        private async void DownloadButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(DownloadUrlTextBox.Text))
            {
                MessageBox.Show("Please fill in the black space.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (!Regex.IsMatch(DownloadUrlTextBox.Text, @"http:\/\/home\.ebs\.co\.kr\/home1810\/replay\/.{2}\/view"))
            {
                MessageBox.Show("Please make sure you entered the correct address.", "Invalid URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Parse HTML
            var html = CQ.CreateFromUrl(DownloadUrlTextBox.Text);

            // Get Info from HTML
            TitleLabel.Text = html["h5"].Text().Trim();
            DateLabel.Text  = html["p.date"].Text().Trim().Replace('.', '-');

            // Download mp3
            var audio = ExtractAudioSource(html["div.body_in script"].ElementAt(1).InnerText);

            saveFileDialog.FileName = ExtractFilePath(audio);
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                await DownloadFileAsync(audio, saveFileDialog.FileName);
            }
        }
Esempio n. 13
0
        static public string[] GetSongArtist(string url)
        {
            string[] artists;
            try
            {
                if (Uri.TryCreate(url, UriKind.Absolute, out link))
                {
                    var dom = CQ.CreateFromUrl(link.ToString());

                    int count = dom[@"div.col-md-4 div.card-body ul.list-unstyled li:nth-of-type(1) a"].Count();
                    artists = new string[count];
                    for (int i = 0; i < count; i++)
                    {
                        int cur = i + 1;
                        artists[i] = dom[@"div.col-md-4 div.card-body ul.list-unstyled li:nth-of-type(1) a[href]:nth-of-type(" + cur + ")"].Text();
                    }
                    return(artists);
                }
                else
                {
                    return(new string[1] {
                        "Unknow"
                    });
                }
            }
            catch (Exception)
            {
                return(new string[1] {
                    "Unknow"
                });
            }
        }
Esempio n. 14
0
        //WORK WITH ROBOTS TXT

        public UrlClass checkUrl(String url)
        {
            UrlClass urlClass = new UrlClass();

            url = urlClass.checkUrl(url);


            if (url == null)
            {
                MessageBox.Show("Нет доступа к сайту или не верно введена ссылка");
                return(null);
            }

            var    dom  = CQ.CreateFromUrl(url);
            string text = dom["meta"].ToString();

            // MessageBox.Show(text.Contains("charset=\"UTF-8\"").ToString());
            if (!text.ToLower().Contains("charset=utf-8"))
            {
                if (!text.ToLower().Contains("charset=\"utf-8\""))
                {
                    MessageBox.Show("На данной веб-странице не используется UTF-8");
                    return(null);
                }
            }

            return(urlClass);
        }
Esempio n. 15
0
        public ActionResult getDetail(string url)
        {
            CQ     dom      = CQ.CreateFromUrl("http://www.alhurra.com" + url);
            string aTitle   = "";
            string aImg_url = "";
            string aText    = "";

            CQ cTitle = dom.Find("h1.pg-title").Eq(0);

            if (cTitle.Length != 0)
            {
                aTitle = cTitle.Text();
            }

            CQ cImg = dom.Find(".cover-media").Eq(0).Find("img").Eq(0);

            if (cImg.Length != 0)
            {
                aImg_url = cImg.Attr("src").ToString();
            }

            CQ cText = dom.Find(".wsw").Eq(0);

            if (cText.Length != 0)
            {
                aText = cText.RenderSelection().ToString();
            }

            ViewBag.aTitle = aTitle;
            ViewBag.aImg   = aImg_url.Replace("_w250_r1", "_w1023_r1");
            ViewBag.aText  = aText;
            return(View());
        }
Esempio n. 16
0
        public DiningWebpageParser(string url)
        {
            Url = url;

            CQ  document = CQ.CreateFromUrl(Url);
            var days     = document["#block-system-main > div > div > div.field.field-name-body.field-type-text-with-summary.field-label-hidden > div > div > table:nth-child(2) > tbody td"];

            foreach (var day in days)
            {
                if (day.FirstChild.HasAttribute("href"))
                {
                    DateTime cur     = DateTime.Parse(day.FirstChild.InnerText);
                    string   linkUrl = day.FirstChild["href"];

                    if (!linkUrl.EndsWith("pdf"))
                    {
                        CQ tempdoc = CQ.CreateFromUrl(linkUrl);
                        PdfList.Add(cur, tempdoc["a"].Where(d => d.HasAttribute("href")).First(d => d["href"].EndsWith("pdf"))["href"]);
                    }
                    else
                    {
                        PdfList.Add(cur, linkUrl);
                    }
                }
            }
        }
Esempio n. 17
0
        // GET: Forex
        public ActionResult Index()
        {
            ArrayList newsList    = new ArrayList();
            CQ        dom         = CQ.CreateFromUrl("http://www.financemagnates.com/forex");
            CQ        mainArticle = dom.Find("ul.featured_cats_wrapper").Eq(0);

            for (int i = 0; i < mainArticle.Children().Length; i++)
            {
                CQ       article = mainArticle.Children().Eq(i).Find("a").Eq(0);
                newsData nData   = new newsData();
                nData.text    = article.Text();
                nData.alt_url = article.Attr("href").ToString();
                nData.url     = "";
                newsList.Add(nData);
            }
            CQ       addArticle = dom.Find("div.sub-feature").Eq(0);
            newsData firstNews  = new newsData();
            CQ       first      = addArticle.Children("article").Eq(0);

            firstNews.text    = first.Find("a").Eq(0).Find("div").Eq(0).Text();
            firstNews.url     = first.Find("a").Eq(0).Css("background-image");
            firstNews.alt_url = first.Find("a").Eq(0).Attr("href").ToString();
            newsList.Add(firstNews);

            newsData secondNews = new newsData();
            CQ       second     = addArticle.Children("article").Eq(1);

            secondNews.text    = second.Find("a").Eq(0).Find("div").Eq(0).Text();
            secondNews.url     = second.Find("a").Eq(0).Css("background-image");
            secondNews.alt_url = second.Find("a").Eq(0).Attr("href").ToString();
            newsList.Add(secondNews);

            ViewBag.newsList = newsList;
            return(View());
        }
        public static List <ProductInfo> getProductHome(string url = "http://buyee.jp/yahoo/auction?lang=ja")
        {
            List <ProductInfo> list = new List <ProductInfo>();
            var dom  = CQ.CreateFromUrl(url);
            CQ  divs = dom.Select(".rcmd_item_field .rcmd_product_whole");

            foreach (var item in divs.ToList())
            {
                string name     = CQ.Create(item)["div.rcmd_product_title a"].Select(x => x.Cq().Text()).FirstOrDefault().ToString().Trim();
                string itemcode = CQ.Create(item)["div.rcmd_product_title a"].Select(x => x.Cq().Attr("href")).FirstOrDefault().ToString().Trim();
                itemcode = itemcode.Substring(itemcode.LastIndexOf('/') + 1);
                string image = CQ.Create(item)["img.rcmd_product_image"].Select(x => x.Cq().Attr("src")).FirstOrDefault().ToString().Trim();
                string pri   = CQ.Create(item)["div.rcmd_product_price"].Select(x => x.Cq().Text()).FirstOrDefault().ToString().Trim();
                pri = Regex.Matches(pri, @"[0-9]*[\.,]?[0-9]+")[0].Value;

                //string auc = CQ.Create(item)["p.product_remaining"].Select(x => x.Cq().Html()).FirstOrDefault().ToString().Trim();
                //auc = auc.Replace("generalicon-clock", "glyphicon glyphicon-ok-circle");
                ProductInfo pro = new ProductInfo()
                {
                    image    = image,
                    name     = name,
                    price    = Convert.ToDouble(pri),
                    itemCode = WebUtility.HtmlDecode(itemcode).Replace("%3A", "-")
                               //,auction=auc
                };
                list.Add(pro);
            }
            return(list);
        }
Esempio n. 19
0
        public ActionResult getDetail(string url)
        {
            CQ dom     = CQ.CreateFromUrl(url);
            CQ article = dom.Find("article.post").Eq(0);
            CQ aMain   = article.Children("div.entry-content").Eq(0);
            CQ ads     = aMain.Find("div.mobile");

            ads.Remove();
            CQ entry = aMain.Find("div.entry-meta");

            entry.Remove();
            string hText = aMain.RenderSelection().ToString();

            CQ     img    = dom.Find("div.site-header-bg").Eq(0);
            string srcImg = "";

            if (img.Length != 0)
            {
                srcImg = img.Css("background-image").ToString();
            }
            //string srcImg = "";
            ViewBag.hText  = hText;
            ViewBag.srcImg = srcImg;
            ViewBag.aTitle = dom.Find("div.hero-text").Eq(0).Children("h1").Eq(0).Text();
            return(View());
        }
    public static void Main()
    {
        CQ dom    = CQ.CreateFromUrl("http://csgolounge.com/match?m=4961");
        CQ bold   = dom["div > a b"];
        CQ italic = dom["div > a i"];

        string team1        = Scraper.RemoveHTMLTags(bold[0].Render());
        string team2        = Scraper.RemoveHTMLTags(bold[1].Render());
        string team1Percent = Scraper.RemoveHTMLTags(italic[0].Render());
        string team2Percent = Scraper.RemoveHTMLTags(italic[1].Render());

        if (Scraper.FindWinner(team1))
        {
            Console.WriteLine("-- Winner --");
            Console.WriteLine(team1 + " - " + team1Percent);
            Console.WriteLine("-- Loser --");
            Console.WriteLine(team2 + " - " + team2Percent);
        }
        else
        {
            Console.WriteLine("-- Winner --");
            Console.WriteLine(team2 + " - " + team1Percent);
            Console.WriteLine("-- Loser --");
            Console.WriteLine(team1 + " - " + team2Percent);
        }
    }
Esempio n. 21
0
        public static List <string> GetAllTeamsLinks(string path)
        {
            var dom   = CQ.CreateFromUrl(path);
            var links = dom[".teams--qualified a"].Select(x => "http://www.uefa.com" + x.GetAttribute("href").Replace("/index.html", "/squad/index.html")).ToList();

            return(links);
        }
Esempio n. 22
0
        public string generaLinkDescarga()
        {
            string link = "";

            if (!url.Contains(".mp3"))
            {
                try
                {
                    var dom = CQ.CreateFromUrl(url).Select("head").First();

                    link = CQ.Create(dom).Select("script").Last().Text();
                    link = link.Trim();
                    link = link.Replace("var my_data = '\"", "");
                    link = link.Replace("\"';", "");
                    link = link.Replace("\\/", "/");

                    var request = (HttpWebRequest)WebRequest.Create(link);
                    request.Timeout           = 5000;
                    request.AllowAutoRedirect = false;

                    var response = (HttpWebResponse)request.GetResponse();
                }
                catch (Exception e)
                {
                    return(url);
                }

                url = link;
            }

            return(url);
        }
Esempio n. 23
0
        static private void FillDbCities(string url)
        {
            CWtrContext db = new CWtrContext();

            CQ dom = new CQ();

            dom = CQ.CreateFromUrl(url);

            CQ CityModuls = dom[".place-list"];

            foreach (var modul in CityModuls)
            {
                CQ Modul = modul.Render();

                CQ cityListCQ = Modul["a"];

                List <Cityes> listCities = new List <Cityes>();

                for (int i = 0; i < cityListCQ.Count(); i++)
                {
                    CQ name = cityListCQ[i].InnerText;
                    Console.WriteLine(name.ToString());
                    Cityes city = new Cityes();
                    city.City = name.ToString();
                    listCities.Add(city);
                }

                db.Cityes.AddRange(listCities);
                db.SaveChanges();
            }
        }
Esempio n. 24
0
        public CloseVoteQueueStats GetOverallQueueStats()
        {
            var doc        = CQ.CreateFromUrl("http://stackoverflow.com/review/close/stats");
            var statsTable = doc.Find("table.task-stat-table");
            var cells      = statsTable.Find("td");

            var stats = new CloseVoteQueueStats();

            stats.NeedReview = int.Parse(cells
                                         .ElementAt(0)
                                         .FirstElementChild
                                         .InnerText, NumberStyles.AllowThousands);

            stats.ReviewsToday = int.Parse(cells
                                           .ElementAt(1)
                                           .FirstElementChild
                                           .InnerText, NumberStyles.AllowThousands);

            stats.ReviewsAllTime = int.Parse(cells
                                             .ElementAt(2)
                                             .FirstElementChild
                                             .InnerText, NumberStyles.AllowThousands);

            return(stats);
        }
Esempio n. 25
0
        public string Get(string sigla)
        {
            string output = "";
            var    dom    = CQ.CreateFromUrl("http://200.147.99.191/acao/cotacoes-historicas.html?codigo=MXRF11.SA&beginDay=4&beginMonth=12&beginYear=2018&endDay=4&endMonth=12&endYear=2019&size=500&page=1&period=ano");

            var rows = dom.Select("#tblInterday tr");

            //id=tblInterday
            foreach (var row in rows.Has("td"))
            {
                try
                {
                    CQ tdcells = row.Cq().Find("td");

                    System.Collections.Generic.List <IDomObject> td = tdcells.ToList();
                    FundoPocs f = new FundoPocs();
                    f.Data            = f.DataBR2US(td[0].InnerText);
                    f.Cotacao         = f.MoneyBR2US(td[1].InnerText);
                    f.ValorMinimo     = f.MoneyBR2US(td[2].InnerText);
                    f.ValorMaximo     = f.MoneyBR2US(td[3].InnerText);
                    f.Variacao        = f.MoneyBR2US(td[4].InnerText);
                    f.VariacaoPercent = f.MoneyBR2US(td[5].InnerText);
                    f.Volume          = Int32.Parse(td[6].InnerText.Replace(".", ""));

                    output += Newtonsoft.Json.JsonConvert.SerializeObject(f);
                }
                catch (Exception ex)
                {
                }
            }
            return(output);
        }
Esempio n. 26
0
        public HtmlParser(string targetUrl)
        {
            url = targetUrl;
            try
            {
                var promise  = CQ.CreateFromUrl(url);
                var textFull = promise.Find("#article_full_text p");

                string fullTextString = textFull.Text();
                //WebClient wc = new WebClient();
                //wc.Encoding = Encoding.UTF8;
                //string html = wc.DownloadString("http://ria.ru/world/20160125/1364783109.html");
                //WebRequest wr = WebRequest.Create(url);
                //wr.Credentials = CredentialCache.DefaultNetworkCredentials;
                //HttpWebResponse response = (HttpWebResponse)wr.GetResponse();
                //if (response.StatusCode != HttpStatusCode.OK)
                //{
                //    throw new Exception(response.StatusDescription);
                //}
                //using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                //{
                //    html = sr.ReadToEnd();
                //}
                //response.Close();
                string n = "123";
            }
            catch
            {
                // what you gonna do?
            }
        }
        public IEnumerable <IWebProxy> GetProxies()
        {
            var result = new List <IWebProxy>();

            Log.Instance.Debug($"[CoolProxyNetProxiesSource.GetProxies] Enumerating proxies...");
            foreach (var pageUri in GetPagesUris().Take(PagesToEnumerate))
            {
                try
                {
                    var cq = CQ.CreateFromUrl(pageUri);

                    var proxiesRows = cq["table tr"].Select(x => x.Render());

                    foreach (var proxyRow in proxiesRows)
                    {
                        IWebProxy proxy;
                        if (!TryToParseProxy(proxyRow, out proxy))
                        {
                            continue;
                        }

                        result.Add(proxy);
                    }
                }
                catch (Exception)
                {
                    continue;
                }
            }
            Log.Instance.Debug($"[CoolProxyNetProxiesSource.GetProxies] Proxies list: \r\n\t{string.Join("\r\n\t", result)}");

            return(result);
        }
Esempio n. 28
0
        private List <DailyFXEvent> ProcessInZhCNnZhTW(string url)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            var dom = CQ.CreateFromUrl(url);

            return(ProcessInZhCNnZhTW(dom));
        }
        public static List <string> ExtractTeamsNames()
        {
            var path  = PremierLeagueSitePath + "/en-gb/matchday/league-table.html?season=2015-2016";
            var dom   = CQ.CreateFromUrl(path);
            var clubs = dom[".col-club"].Select(x => x.Cq().Text().Trim()).ToList().Skip(1).Take(20).ToList();

            return(clubs);
        }
Esempio n. 30
0
        public static bool CheckLicense()
        {
            var hwid = GetHardwareID();

            return(CQ.CreateFromUrl(LicenseDataUrl)["td"]
                   .Map(x => x.Cq().Text())
                   .Any(x => x == hwid));
        }