تكليفات الدروس من [ 141 ] إلى [ 141 ]
[ 2 ] تكليفات على [ Web Scraping ]
التكليف 01
- احفظ HTML الموجود تحت في ملف products.html جنب ملف Python ومتغيرش محتواه
- باستخدام Selenium افتح الملف المحلي واطبع عنوان الصفحة وأسماء المنتجات بالترتيب
- استخدم find_elements لاختيار كل العناصر المطابقة واقفل المتصفح حتى لو حصل خطأ
- المطلوب استخراج النص مش كتابة أسماء المنتجات يدويا
<!DOCTYPE html>
<html lang="en"><head><title>Products</title></head><body>
<h2 class="product">Keyboard</h2>
<h2 class="product">Mouse</h2>
<h2 class="product">Monitor</h2>
</body></html>الناتج المطلوب
Products
Keyboard
Mouse
Monitor
التكليف 02
- احفظ الكود في links.html جنب ملف Python واستخرج نص وروابط a اللي ليها class باسم course فقط
- متطبعش رابط Contact
- اطبع عدد العناصر المطابقة للكلاس missing من غير ما يحصل خطأ
- وضح الفرق بين find_element و find_elements لما مفيش عنصر مطابق
<!DOCTYPE html>
<html lang="en"><head><title>Courses</title></head><body>
<a class="course" href="https://example.com/html">HTML</a>
<a class="course" href="https://example.com/python">Python</a>
<a href="https://example.com/contact">Contact</a>
</body></html>الناتج المطلوب
HTML https://example.com/html
Python https://example.com/python
0