PDA المساعد الشخصي الرقمي

عرض كامل الموضوع : برمجة عناكب الويب: [ الجزء الثاني ] ماسح صفحات المنتديات



Diamond mas
05-09-2014, 15:15
http://www.mexat.com/vb/attachment.php?attachmentid=2024658&d=1408547376

بسم الله الرحمن الرحيم
السلام عليكم ورحمة الله وبركاته


شاهدنا في الموضوع السابق أكواد بناء برنامج لمسح الصفحة الرئيسية للمنتدى واستخراج أسماء الأقسام وروابطها وعرضها بطريقة شجرية باستخدام المتحكم TreeView،
وشاهدنا بطريقة سريعة كيفية إنشاء مشروع جديد وكيفية إضافة ملفات للمشروع وكيفية ربط الأكواد مع بعضها وإنشاء تطبيق ذو واجهة رسومية للمستخدمين.

في هذا الموضوع سنكمل الأكواد وسنطرح المرحلة الثانية من عمل برنامج البحث الذي تحدثنا عنه في الموضوع الأول،
وفي هذه المرحلة سنضيف الأكواد التي تقوم بمسح الأقسام بحثاً عن المواضيع،
ثم سنستعمل تلك الأكواد للبحث داخل الأقسام في مثال بسيط على عمل البرنامج،

بعد هذه المرحلة يتبقى طرح أكواد الواجهة التطبيقة الكاملة لبرنامج البحث ومتابعة طريقة عملها، وتلك سنتناولها في الموضوع القادم بإذن الله.

تابعوا معي.. :D

Diamond mas
05-09-2014, 15:16
قائمة الفئات

سنضيف إلى المشروع المكتبي MAS.ForumScraper فئات جديدة ستكون كما في القائمة التالية
ولمن فاته الموضوع السابق يستطيع تحميل ملفات الجزء السابق ليتمكن من التابعة.. التحميل من الرابط ()

- vBThread
وهي الفئة التي تحوي معلومات المواضيع (من عنوان وروابط ..الخ.) التي سيتم استخراجها.

- مجموعة فئات بيانات الأحداث لتنظيم عملية البحث، وهذه الفئات هي:
* ScrapProgressEventArgs
*PageErrorEventArgs
* PageLoadingEventArgs

- VBForumScraper
وهي الفئة الرئيسية التي تقوم بالبحث.

كما وضحت في المواضيع السابقة سأقوم بطرح أكواد هذه الفئات وسأترك المجال مفتوحاً لمناقشتها،
فلا تترددوا بالسؤال عن أي نقطة أو تنبيهي على أي ملاحظة تشاهدونها :رامبو:

الأكواد في المشاركات القادمة ;)

Diamond mas
05-09-2014, 15:18
الفئة vBThread

اختصاراً للوقت والجهد سأدعكم مع الكود وتذكروا أن الموضوع مفتوح لاستفساراتكم :رامبو:



/*
* vBThread.cs
*
* Copyright (C) 2014 M.A.S <http://www.mexat.com/vb/member.php?u=175841>
*
* LICENSE (MIT License)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MAS.ForumScraper
{
public class vBThread
{
// عنوان الموضوع.
public string Title { get; set; }

// المنتدى الذي ينتمي له.
public string ParentForum { get; set; }

// اسم كاتب الموضوع.
public string AuthorName { get; set; }

// رابط الموضوع.
[System.Xml.Serialization.XmlIgnore]
public Uri Url { get; set; }

// رابط ملف كاتب الموضوع.
[System.Xml.Serialization.XmlIgnore]
public Uri AuthorUrl { get; set; }

// رابط الموضوع بصيغة نص.
[System.Xml.Serialization.XmlElement("Url")]
public string UrlAbsoluteUri
{
get { return Url.AbsoluteUri; }
set { Url = new Uri(value); }
}

// رابط ملف كاتب الموضوع بصيغة نص.
[System.Xml.Serialization.XmlElement("AuthorUrl")]
public string AuthorUrlAbsoluteUri
{
get { return AuthorUrl.AbsoluteUri; }
set { AuthorUrl = new Uri(value); }
}

public vBThread() { }
public vBThread(string title, Uri url, string forum = "", string author_name = "", Uri author_url = null)
{
Title = title;
Url = url;
ParentForum = forum;
AuthorName = author_name;
AuthorUrl = author_url;
}
}
}

Diamond mas
05-09-2014, 15:19
فئات بيانات الأحداث (Event Args)

اختصاراً للوقت والجهد سأدعكم مع الأكواد وتذكروا أن الموضوع مفتوح لاستفساراتكم :رامبو:


***** الفئة PageLoadingEventArgs *****



/*
* PageLoadingEventArgs.cs
*
* Copyright (C) 2014 M.A.S <http://www.mexat.com/vb/member.php?u=175841>
*
* LICENSE (MIT License)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MAS.ForumScraper
{
public class PageLoadingEventArgs : EventArgs
{
public Uri PageUri { get; set; }
}
}



.
.

***** الفئة ScrapProgressEventArgs *****



/*
* ScrapProgressEventArgs.cs
*
* Copyright (C) 2014 M.A.S <http://www.mexat.com/vb/member.php?u=175841>
*
* LICENSE (MIT License)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MAS.ForumScraper
{
public class ScrapProgressEventArgs : EventArgs
{
public List<vBThread> Results { get; set; }
public int ParsedPages { get; set; }
public Uri PageUrl { get; set; }
public string PageTitle { get; set; }
}
}



.
.

***** الفئة ScrapProgressEventArgs *****



/*
* PageErrorEventArgs.cs
*
* Copyright (C) 2014 M.A.S <http://www.mexat.com/vb/member.php?u=175841>
*
* LICENSE (MIT License)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MAS.ForumScraper
{
public class PageErrorEventArgs : EventArgs
{
public Uri PageUri { get; set; }
public bool Retry { get; set; }
public Exception Error { get; set; }
}
}

Diamond mas
05-09-2014, 15:21
فئة البحث الرئيسية

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

يمكنكم تحميله من الروابط التالية:

Diamond mas
05-09-2014, 15:22
تجربة عملية للكود

سنستخدم في هذه التجربة المشاريع التي قمنا بإنشاءها في الموضوع السابق،
صورة للبرنامج الناتج عند مسح المنتدى العام

http://www.mexat.com/vb/attachment.php?attachmentid=2028794&stc=1&d=1409929898


روابط تحميل الملفات الناتجة بعد تطبيق كل ما في هذا الموضوع:
لتجربة تشغيل البرنامج تفضلوا
أرجو المعذرة لأني لم أقم بشرح تفاصيل إنشاء التجربة، والسبب هو أني لم أجد أي متابعة في موضوعي السابق..
تستطيعون تحميل الأكواد وتجربتها والموضوع مفتوح لاستفساراتكم وملاحظاتكم ^_^


أنتظركم :رامبو:

بن سنان
29-09-2014, 21:01
السلام عليكم ورحمة الله وبركاتة
جزاك الله خير اخي ديمون ورحم الله والديك
درس جميل ابدعت في طرحة . لاتنسى اخي ان الصبر ياتي بنتائج طيبة
وان شاء الله تجد متابعين لدروس النادرة

Diamond mas
30-09-2014, 10:33
السلام عليكم ورحمة الله وبركاتة
جزاك الله خير اخي ديمون ورحم الله والديك
درس جميل ابدعت في طرحة . لاتنسى اخي ان الصبر ياتي بنتائج طيبة
وان شاء الله تجد متابعين لدروس النادرة

وعليكم السلام ورحمة الله وبركاته

شكراً لك أخي وإياكم يا رب ^_^

لن يذهب الشرح إلى أي مكان وبإمكان الجميع التعلم والاستفادة من هذه المواضيع في أي وقتِ شاؤوا :d

تحياتي

mmnon.com
30-09-2014, 11:47
كالعادة إبداع رائع

وطرح يستحق المتابعة

شكراً لك

Diamond mas
01-10-2014, 08:17
أهلاً بك أخي ^_^
منور :أوو:

hoss007
19-10-2014, 11:35
شكرا على الموضوع

الف شكر