The main purpose is to make multiple threads basing on count of pages. Is there any way to make it easier than just making ton of if
s? Cannot get an idea of how to solve this properly.
import threading
from bs4 import BeautifulSoup
from os import system, name
import requests
import sqlite3
import time
from dhooks import Webhook, Embed
import pprint
from threading import Thread
def page_check(URL):
page = requests.get(URL)
soup = BeautifulSoup(page.text, 'html.parser')
products = soup.find('div', attrs={'class': 'category-products'}).findAll('ul', attrs={'class': 'products-grid'})
print(products)
def page_start(count):
count = str(count)
URL = 'html/page/' + count + '/ke'
threading.Thread(target=page_check(URL)).start()
def number_of_pages():
URL = 'html/page/'
sites = requests.get(URL)
soup = BeautifulSoup(sites.text, 'html.parser')
number = soup.find('p', attrs={'class': 'amount mobilehidden'}).text
number = number.split()
number = int(number[5])
pages1 = number / 48
pages2 = int(number / 48)
if (pages1 / pages2) > 1:
pages = pages2 + 1
elif (pages1 / pages2) == 1:
pages = pages2
return pages
def main():
pages = number_of_pages()
if pages == 1:
threading.Thread(target=page_check('htmlpage/p/1/limit/48.html')).start()
if pages == 2:
threading.Thread(target=page_check('htmlpage/p/1/limit/48.html')).start()
threading.Thread(target=page_check('htmlpage/p/2/limit/48.html')).start()
if pages == 3:
threading.Thread(target=page_check('htmlpage/p/1/limit/48.html')).start()
threading.Thread(target=page_check('htmlpage/p/2/limit/48.html')).start()
threading.Thread(target=page_check('htmlpage/p/3/limit/48.html')).start()
main()