Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 10 của 10
  1. #1

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    thế có cách nào đọc được ko bạn

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi son0nline
    mình dung code này để lấy mấy trang khác thì được mà trang zing nó toàn ra cái khỉ gì ấy
    rất mong được hỗ trợ
    Mã:
                WebClient client = new WebClient();
    
                richTextBox1.Text = client.DownloadString(txtUrl.Text);
    dung code này lấy html của zing mp3 thì nó toàn ra mã link tink thôi[IMG]images/smilies/17.gif[/IMG]
    Lấy để làm gì thế bạn

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Cách lấy mã html với (đặc biệt là trang zing mp3)?

    mình dung code này để lấy mấy trang khác thì được mà trang zing nó toàn ra cái khỉ gì ấy
    rất mong được hỗ trợ
    Mã:
                WebClient client = new WebClient();
    
                richTextBox1.Text = client.DownloadString(txtUrl.Text);
    dung code này lấy html của zing mp3 thì nó toàn ra mã link tink thôi[IMG]images/smilies/17.gif[/IMG]

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    mình thử làm cái trình nghe nhạc lấy dữ liệu từ zing
    mà không đọc được thì lấy làm sao
    mình thử thấy bằng webbrows của c# thì lấy được nhưng nhạc nó phát ầm lên
    có ai giúp mình với

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Bạn có thể vào mp3.zing.vn bằng phiên bản mobile.
    Link ở đây http://m.mp3.zing.vn
    Vì là mobile nên load xong nó ko tự play nhạc luôn

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    vẫn chạy điên cuồng

  8. #8
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi son0nline
    mình dung code này để lấy mấy trang khác thì được mà trang zing nó toàn ra cái khỉ gì ấy
    rất mong được hỗ trợ
    Mã:
                WebClient client = new WebClient();
    
                richTextBox1.Text = client.DownloadString(txtUrl.Text);
    dung code này lấy html của zing mp3 thì nó toàn ra mã link tink thôi[IMG]images/smilies/17.gif[/IMG]
    Code của bạn đây:

    Mã:
            public List<MusicDescription> GetAllMusicFromLink(string url)        {            List<MusicDescription> lstMusic = new List<MusicDescription>();            HttpWebRequest request = null;                        request = (HttpWebRequest)WebRequest.Create(url);            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;            HttpWebResponse response =(HttpWebResponse)request.GetResponse();            StreamReader strRead = null;            if (response.CharacterSet == null)                strRead = new StreamReader(response.GetResponseStream());            else                strRead = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));            //Lấy mã html            string htmlContent = strRead.ReadToEnd();                        RichTextBox rtb = new RichTextBox();            rtb.Text = htmlContent;            int index = rtb.Find("xmlURL=");            string urlXML = "";            for (int i = index+7; i < rtb.Text.Length; i++)            {                urlXML += rtb.Text[i].ToString();                 string continueChar = rtb.Text[i + 1].ToString() + rtb.Text[i + 2].ToString()                                        + rtb.Text[i + 3].ToString() + rtb.Text[i + 4].ToString();                if (continueChar == "&amp")                {                    break;                }            }            //Tải tập tin XML về            request = (HttpWebRequest)WebRequest.Create(urlXML);            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;            response = (HttpWebResponse)request.GetResponse();            strRead = new StreamReader(response.GetResponseStream());            XmlDocument xmlDoc = new XmlDocument();            string sourceXML = strRead.ReadToEnd();            xmlDoc.LoadXml(sourceXML);            XmlNodeList nodes = xmlDoc.ChildNodes[0].ChildNodes;            int j = 0;            j = nodes.Count == 1 ? 0 : 1;            while (j < nodes.Count)            {                MusicDescription music = new MusicDescription();                music.Title = nodes[j].SelectSingleNode("title").InnerText;                music.Performer = nodes[j].SelectSingleNode("performer").InnerText;                music.Source = nodes[j].SelectSingleNode("source").InnerText;                if (music.Source.Trim() == string.Empty) music.Source = "<Không có link>";                lstMusic.Add(music);                j++;            }            response.Close();            strRead.Close();            return lstMusic;        }
    Quan trọng là thằng này nhá:
    Mã:
    request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
    - - - Nội dung đã được cập nhật ngày 10-03-2014 lúc 12:03 AM - - -

    Trích dẫn Gửi bởi son0nline
    mình dung code này để lấy mấy trang khác thì được mà trang zing nó toàn ra cái khỉ gì ấy
    rất mong được hỗ trợ

    Mã:
                WebClient client = new WebClient();             richTextBox1.Text = client.DownloadString(txtUrl.Text);
    dung code này lấy html của zing mp3 thì nó toàn ra mã link tink thôi[IMG]images/smilies/17.gif[/IMG]
    Code của bạn đây:

    Mã:
            public List<MusicDescription> GetAllMusicFromLink(string url)        {            List<MusicDescription> lstMusic = new List<MusicDescription>();            HttpWebRequest request = null;                        request = (HttpWebRequest)WebRequest.Create(url);            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;            HttpWebResponse response =(HttpWebResponse)request.GetResponse();            StreamReader strRead = null;            if (response.CharacterSet == null)                strRead = new StreamReader(response.GetResponseStream());            else                strRead = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));            //Lấy mã html            string htmlContent = strRead.ReadToEnd();                        RichTextBox rtb = new RichTextBox();            rtb.Text = htmlContent;            int index = rtb.Find("xmlURL=");            string urlXML = "";            for (int i = index+7; i < rtb.Text.Length; i++)            {                urlXML += rtb.Text[i].ToString();                 string continueChar = rtb.Text[i + 1].ToString() + rtb.Text[i + 2].ToString()                                        + rtb.Text[i + 3].ToString() + rtb.Text[i + 4].ToString();                if (continueChar == "&amp")                {                    break;                }            }            //Tải tập tin XML về            request = (HttpWebRequest)WebRequest.Create(urlXML);            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;            response = (HttpWebResponse)request.GetResponse();            strRead = new StreamReader(response.GetResponseStream());            XmlDocument xmlDoc = new XmlDocument();            string sourceXML = strRead.ReadToEnd();            xmlDoc.LoadXml(sourceXML);            XmlNodeList nodes = xmlDoc.ChildNodes[0].ChildNodes;            int j = 0;            j = nodes.Count == 1 ? 0 : 1;            while (j < nodes.Count)            {                MusicDescription music = new MusicDescription();                music.Title = nodes[j].SelectSingleNode("title").InnerText;                music.Performer = nodes[j].SelectSingleNode("performer").InnerText;                music.Source = nodes[j].SelectSingleNode("source").InnerText;                if (music.Source.Trim() == string.Empty) music.Source = "<Không có link>";                lstMusic.Add(music);                j++;            }            response.Close();            strRead.Close();            return lstMusic;        }
    Quan trọng là thằng này nhá:
    Mã:
    request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
    My channel: http://www.youtube.com/userguyenvukiet

  9. #9
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    cảm ơn bạn mình lấy được rồi

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Mã:
    RichTextBox rtb = new RichTextBox();
                rtb.Text = htmlContent;
                int index = rtb.Find("xmlURL=");
                string urlXML = "";
                for (int i = index+7; i < rtb.Text.Length; i++)
                {
                    urlXML += rtb.Text[i].ToString();
     
                    string continueChar = rtb.Text[i + 1].ToString() + rtb.Text[i + 2].ToString()
                                            + rtb.Text[i + 3].ToString() + rtb.Text[i + 4].ToString();
                    if (continueChar == "&amp")
                    {
                        break;
                    }
                }
    thay vào
    Mã:
    string RegexPatternUrlXML = @"<embed.*?xmlURL=(?<urlXML>.*?)&textad=[""']";
                string urlXML = Regex.Match(data, RegexPatternUrlXML, RegexOptions.IgnoreCase).Groups["urlXML"].Value;

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •