Исправлен пример кода в Pars
This commit is contained in:
@@ -55,6 +55,11 @@ nameFolder = 'img'
|
|||||||
# The first results are what we wanted, and the rest are not. Therefore, we prefer to get the first 84 elements
|
# The first results are what we wanted, and the rest are not. Therefore, we prefer to get the first 84 elements
|
||||||
locator = 'b_NgmZrVnRtV8MZMEjLs'
|
locator = 'b_NgmZrVnRtV8MZMEjLs'
|
||||||
allCards = soup.find_all(class_=locator)[:84]
|
allCards = soup.find_all(class_=locator)[:84]
|
||||||
|
if len(allCards) == 0:
|
||||||
|
print(f'''Something went wrong. Here is a list of possible causes:
|
||||||
|
1) DuckDuckGo has changed the class for video cards. The code uses the locator "{locator}"
|
||||||
|
2) The site did not load. Try increasing the timeSleep parameter or make a request later.''')
|
||||||
|
return
|
||||||
|
|
||||||
# Getting all images
|
# Getting all images
|
||||||
allImg = [card.find('img') for card in allCards]
|
allImg = [card.find('img') for card in allCards]
|
||||||
|
|||||||
+3
-3
@@ -60,9 +60,9 @@ def main():
|
|||||||
locator = 'b_NgmZrVnRtV8MZMEjLs'
|
locator = 'b_NgmZrVnRtV8MZMEjLs'
|
||||||
allCards = soup.find_all(class_=locator)[:84]
|
allCards = soup.find_all(class_=locator)[:84]
|
||||||
if len(allCards) == 0:
|
if len(allCards) == 0:
|
||||||
print(f'''Something went wrong. Here is a list of possible causes:
|
print(f'''Что-то пошло не так. Вот список возможных проблем:
|
||||||
1) DuckDuckGo has changed the class for video cards. The code uses the locator "{locator}"
|
1) DuckDuckGo изменил назввание класса для карточек с видео. Сейчас используется локатор: "{locator}"
|
||||||
2) The site did not load. Try increasing the timeSleep parameter or make a request later.''')
|
2) Сайт не прогрузился. Попробуй увиличить значени параметра timeSleep или выполни запрос позже.''')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Получаем все изображения
|
# Получаем все изображения
|
||||||
|
|||||||
Reference in New Issue
Block a user