mfaraj57
مسؤول فريق الدريم بوكس (رحمه الله)- إنضم
- 24 أوت 2007
- المشاركات
- 10.037
- مستوى التفاعل
- 49.813
ستظهر لنا الاضافه في عمود الاضافات
نذهب الى موقع moviflex قسم الافلام ونأخذ احد البلوكات التي ذكرناها في الشرح السابق
نجد التقييم مذكور في هذا السطر
ننسخه لوضع جملة regular expresion
نضع الرموز (.*?) مكان رقم 8
فتصبح جملة regular expression
نفتح كود def getmovies في اضافة moviflex في برنامج wTSmedia
ونصيف جملة regular expression على الشكل التالي
نفعل نفس الشىء بالنسبه
الجوده quality
القصه description
السنه year
نضيف الاسطر التاليه في default.py بناء على ما ذكر
نضيف المعلومات في desc,extra الى جملة تخزين المعلومات addDir على الشكل التالي
ننفذ الكود في wTSmedia فنحصل على خطأ نعرفه من خلال اللوغ log window
الخطأ في طريقة حفظ القيم في لقاموس او dictionary
نصحح الكود وننفذه مره ثانيه
الصوره تشير الى انه تم تنفيذ الكود بنجاح
ننقل نفس الكود الى قسم المسلسلات والبحث
في المرفقات default.py بعد اضافة الكود
يتبع.....
نذهب الى موقع moviflex قسم الافلام ونأخذ احد البلوكات التي ذكرناها في الشرح السابق
كود:
<article id="post-27617" class="item movies">
<div class="poster">
<a href="https://www.moviflex.net/movies/the-last-boy/"><img src="https://cdn.moviflex.net/wp-content/uploads/2019/01/ygUsgb6WSTZ4iyZJXpjswgngqBY-185x278.jpg" alt="The Last Boy"></a>
<div class="rating"><span class="icon-star2"></span> 8</div>
<span class="quality">720p</span> </div>
<div class="data">
<h3>
<a href="https://www.moviflex.net/movies/the-last-boy/">The Last Boy</a>
</h3>
<span>2019</span>
</div>
<div class="animation-1 dtinfo">
<div class="title">
<i class="dt-movies"></i>
The Last Boy </div>
<div class="texto">The world at an end, a dying mother sends her young son on a quest to find the place that grants wishes.
مشاهدة فيلم الدراما والخيال العلمي The Last Boy 2019 <div class="degradado"></div></div>
<div class="rating">
<div class="datareviews">
<div class="datarating">
<span class="rating-stars-a">
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
</span>
<span class="rating-stars-b" style="width: 80%;">
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
<i class="icon-star2"></i>
</span>
</div>
<div class="rating_right">
<span class="rating-value">8</span>
<b>/1</b>
</div>
</div>
</div>
</div>
</article>
ننسخه لوضع جملة regular expresion
كود:
<span class="icon-star2"></span> 8</div>
فتصبح جملة regular expression
كود:
regx='''<span class="icon-star2"></span>(.*?)</div>'''
ونصيف جملة regular expression على الشكل التالي
كود:
try:#use try except because if rating not found the code continue to next line and not cause error
regx='''<span class="icon-star2"></span>(.*?)</div>'''#regular expression to extract movie rating
rating=re.findall(regx,block, re.M|re.I)[0]#execute regular expression
title=title+"-"+rating##add rating to the title of the movie
extra{"rating"}=rating##put rating value in dictionary called extra
except:
pass
نفعل نفس الشىء بالنسبه
الجوده quality
القصه description
السنه year
كود:
#<span class="quality">720p</span>
regx='''<span class="quality">(.*?)</span>''' #quality
#<span>2019</span>
regx='''<span>(.*?)</span>
'''#year
#<div class="texto">The world at an end, a dying mother sends her young son on a quest to find the place that grants wishes.
regx='''<div class="texto">(.*?).
'''#description,story
كود:
try:#use try except because if year not found the code continue to next line and not cause error
regx='''<span>(.*?)</span>
'''#year
rating=re.findall(regx,block, re.M|re.I)[0]#execute regular expression
title=title+"-"+year##add year to the title of the movie
extra{"year"}=year##put rating value in dictionary called extra
except:
pass
try:
regx='''<span class="quality">(.*?)</span>''' #quality
quality=re.findall(regx,block, re.M|re.I)[0]#execute regular expression
title=title+"-"+quality##add quality to the title of the movie
extra{"quality"}=quality##put quality value in dictionary called extra
except:
pass
try:#use try except because if rating not found the code continue to next line and not cause error
regx='''<span class="icon-star2"></span>(.*?)</div>'''#regular expression to extract movie rating
rating=re.findall(regx,block, re.M|re.I)[0]#execute regular expression
title=title+"-"+rating##add rating to the title of the movie
extra{"rating"}=rating##put rating value in dictionary called extra
except:
pass
try:
regx='''<div class="texto">(.*?).
'''#description,story
desc=re.findall(regx,block, re.M|re.I)[0]#execute regular expression
except:
desc=''
نضيف المعلومات في desc,extra الى جملة تخزين المعلومات addDir على الشكل التالي
كود:
addDir(title,href,1,image,name,1,extra=extra,desc=desc)
ننفذ الكود في wTSmedia فنحصل على خطأ نعرفه من خلال اللوغ log window
الخطأ في طريقة حفظ القيم في لقاموس او dictionary
كود:
extra{"rating"}= ##wrong
extra['rating']= ##right
الصوره تشير الى انه تم تنفيذ الكود بنجاح
ننقل نفس الكود الى قسم المسلسلات والبحث
في المرفقات default.py بعد اضافة الكود
يتبع.....
المرفقات
التعديل الأخير: