Given a soup I need to get n elements with class="foo".
This can be done by:
soup.find_all(class_='foo', limit=n)
However, this is a slow process, as the elements I'm trying to find are located at the very bottom of the document.
Here is my code:
main_num = 1
main_page = 'https://rawdevart.com/search/?page={p_num}&ctype_inc=0'
# get_soup returns bs4 soup of a link
main_soup = get_soup(main_page.format(p_num=main_num))
# get_last_page returns the number of pages which is 64
last_page_num = get_last_page(main_soup)
for sub_num in range(1, last_page_num+1):
sub_soup = get_soup(main_page.format(p_num=sub_num))
arr_links = sub_soup.find_all(class_='head')
# process arr_links