Jump to content
  • 0
Đoàn Minh Tâm

Hỗ trợ Request pagesource trang web lazada bằng C#

Câu hỏi

Chào mọi người.

Mọi người ai biết Request pagesource html trang Lazada hàng loạt mà không bị check point. Vui lòng hướng dẫn giúp mình.

Mình dùng Webclient để request sync page.

Code demo:

string url = "https://www.lazada.vn/products/dien-thoai-samsung-galaxy-s20-plus-128gb8gb-hang-chinh-hang-moi-100-nguyen-seal-bao-hanh-12-thang-i498830724-s974814141.html?spm=a2o4n.searchlist.list.8.706b3a0fcsJ4Oe&search=1";

                Uri address = new Uri(url);

                WebClient webClient = new WebClient();
                webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

                //< get Website >
                //*here: download as string
                webClient.DownloadStringCompleted += WebClient_DownloadStringCompleted;
                webClient.DownloadStringAsync(address);


private void WebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            //-------------------< WebClient_DownloadStringCompleted() >-------------------
            //< check >
            if (e.Error != null)
            {
                var output = e.Error.Message;
            }
            //</ check >
            else if (e.Result != null)
            {
                richTextBox1.Invoke(new MethodInvoker(delegate () {
                    richTextBox1.Text = e.Result;
                }));
                //var document = new HtmlDocument();
                //document.LoadHtml(e.Result);

                //var node = document.DocumentNode.SelectSingleNode("//span[@id=\"result_box\"]");
                //var output = node != null ? node.InnerText : e.Error.Message;

            }
            //-------------------</ WebClient_DownloadStringCompleted() >-------------------
        }

 

Chia sẻ bài đăng này


Link tới bài viết
Share on other sites

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Trả lời câu hỏi này...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...