منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : حذف العناوين من الروابط
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
السلام عليكم ورحمة الله وبركاته

تحويل كود الاخ سعود من VB.Net الى C#
كود :
           using (System.Net.WebClient wc = new System.Net.WebClient())
           {
               var u = "bidaya.html";
               wc.Encoding = Encoding.UTF8;
               string html = wc.DownloadString(u);
               html = System.Net.WebUtility.HtmlDecode(html);
               // <li><a id="bi" href="http://vb4arb.com/vb/forumdisplay.php?kanal=fid=2">a</a></li>
               var str = "<a.*?>.*?(.*?)</a>";
               System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(str, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
               System.Text.RegularExpressions.MatchCollection mc = reg.Matches(html);
               foreach (System.Text.RegularExpressions.Match h in mc)
               {
                   if (h.Success)
                   {
                       // txt(h.Value)
                       // txt(vbNewLine)
                       var txt = h.Groups[1].Value;
                       html = html.Replace(h.Groups[1].Value, string.Empty);
                   }
               }
           }

ولكن بالكود بالاعلى قمت باضافة كل مكتة تطلب الاستدعاء بكل سطر
فبدلاً من استخدام الكود بهذا الشكل كما بالاعلى 

عليك استخدامه بهذا الشكل
كود :
           using (WebClient wc = new WebClient())
           {
               var u = "bidaya.html";
               wc.Encoding = Encoding.UTF8;
               string html = wc.DownloadString(u);
               html = WebUtility.HtmlDecode(html);
               // <li><a id="bi" href="http://vb4arb.com/vb/forumdisplay.php?kanal=fid=2">a</a></li>
               var str = "<a.*?>.*?(.*?)</a>";
               Regex reg = new Regex(str, RegexOptions.IgnoreCase);
               MatchCollection mc = reg.Matches(html);
               foreach (Match h in mc)
               {
                   if (h.Success)
                   {
                       var txt = h.Groups[1].Value;
                       html = html.Replace(h.Groups[1].Value, string.Empty);
                   }
               }
           }

بعد اتمام الامر قم عمل استدعاء للتالي
كود :
using System.Net;
using System.Text.RegularExpressions;

تحياتى لك
وتمنياتى لك التوفيق
(21-06-19, 06:02 PM)elgokr كتب : [ -> ]
السلام عليكم ورحمة الله وبركاته

تحويل كود الاخ سعود من VB.Net الى C#
كود :
           using (System.Net.WebClient wc = new System.Net.WebClient())
           {
               var u = "bidaya.html";
               wc.Encoding = Encoding.UTF8;
               string html = wc.DownloadString(u);
               html = System.Net.WebUtility.HtmlDecode(html);
               // <li><a id="bi" href="http://vb4arb.com/vb/forumdisplay.php?kanal=fid=2">a</a></li>
               var str = "<a.*?>.*?(.*?)</a>";
               System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(str, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
               System.Text.RegularExpressions.MatchCollection mc = reg.Matches(html);
               foreach (System.Text.RegularExpressions.Match h in mc)
               {
                   if (h.Success)
                   {
                       // txt(h.Value)
                       // txt(vbNewLine)
                       var txt = h.Groups[1].Value;
                       html = html.Replace(h.Groups[1].Value, string.Empty);
                   }
               }
           }

ولكن بالكود بالاعلى قمت باضافة كل مكتة تطلب الاستدعاء بكل سطر
فبدلاً من استخدام الكود بهذا الشكل كما بالاعلى 

عليك استخدامه بهذا الشكل
كود :
           using (WebClient wc = new WebClient())
           {
               var u = "bidaya.html";
               wc.Encoding = Encoding.UTF8;
               string html = wc.DownloadString(u);
               html = WebUtility.HtmlDecode(html);
               // <li><a id="bi" href="http://vb4arb.com/vb/forumdisplay.php?kanal=fid=2">a</a></li>
               var str = "<a.*?>.*?(.*?)</a>";
               Regex reg = new Regex(str, RegexOptions.IgnoreCase);
               MatchCollection mc = reg.Matches(html);
               foreach (Match h in mc)
               {
                   if (h.Success)
                   {
                       var txt = h.Groups[1].Value;
                       html = html.Replace(h.Groups[1].Value, string.Empty);
                   }
               }
           }

بعد اتمام الامر قم عمل استدعاء للتالي
كود :
using System.Net;
using System.Text.RegularExpressions;

تحياتى لك
وتمنياتى لك التوفيق
بارك الله لك وفيك
الله ارزقك الصحة والعافية
شكرا لك اخي الكريم على ما تقدمه للمنتدى

                                             
الشكر لله والحمد لله

والحمد لله على كل حال

تحياتى لك
وتمنياتى لك التوفيق
الصفحات : 1 2