تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
حذف العناوين من الروابط
#11
السلام عليكم ورحمة الله وبركاته

تحويل كود الاخ سعود من 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;

تحياتى لك
وتمنياتى لك التوفيق
{ وَقُل رَّبِّ زِدْنِي عِلْمًا }
[ كن على يقين من اعمالنا نخطئ ومن اخطائنا نتعلم ولذلك لا شي مستحيل ]

ساهم دائماً فى    لكل من يقوم بالمساهمة
فى حل المشكلة او الاستفسار لديك فالجميع هنا يعمل 
على مساعدة الاخرين لوجه الله وان تحتسب له اجر عند الله


 شرح كيفية عمل قاعدة بيانات تعمل على اكثر من جهاز على الشبكة الداخلية
الرد }}}
تم الشكر بواسطة: سعود , ابراهيم ايبو , wared , bidaya
#12
(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;

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

                                             
الرد }}}
تم الشكر بواسطة: elgokr
#13
الشكر لله والحمد لله

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

تحياتى لك
وتمنياتى لك التوفيق
{ وَقُل رَّبِّ زِدْنِي عِلْمًا }
[ كن على يقين من اعمالنا نخطئ ومن اخطائنا نتعلم ولذلك لا شي مستحيل ]

ساهم دائماً فى    لكل من يقوم بالمساهمة
فى حل المشكلة او الاستفسار لديك فالجميع هنا يعمل 
على مساعدة الاخرين لوجه الله وان تحتسب له اجر عند الله


 شرح كيفية عمل قاعدة بيانات تعمل على اكثر من جهاز على الشبكة الداخلية
الرد }}}
تم الشكر بواسطة:


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم