• 13-07-2022, 18:19:33
    #1
    a = 1
    for i in categories:
        urller.append(i)
        while a <= 10:
            driver.get(i+'/?p=' + str(a))
            print(driver.current_url)
            sleep(6)
            save = driver.page_source
            soup = BeautifulSoup(save, "html.parser")
            url = soup.find_all("div", {"class":"contributor-wrap cont__info"})
            kategori = soup.find_all("div", {"class":"tag --disabled --size-md --blue topic"})
            for b in url:
                b = b.find("a")["href"]
                urller.append(b)
            for c in kategori:
                c = c.text
                kategoriler.append(c)   
            a+=1;
    input("2ye geçti")
    x = 1
    for i in countries:
        urller.append(i)
        while x <= 20:
            driver.get(i+'/?p=' + str(a))
            sleep(6)
            print(driver.current_url)
            save = driver.page_source
            soup = BeautifulSoup(save, "html.parser")
            url = soup.find_all("div", {"class":"contributor-wrap cont__info"})
            kategori = soup.find_all("div", {"class":"tag --disabled --size-md --blue topic"})
            for b in url:
                b = b.find("a")["href"]
                urller.append(b)
            for c in kategori:
                c = c.text
                kategoriler.append(c)   
            x+=1;
    categories de 30 link var, categories[0] bunu while ile 10 kere çağırdıktan sonra categories[1] mesela buna geçmeden for ile foru bitirip diğerine geçiyor
  • 13-07-2022, 18:23:33
    #2
    Sanırım çözümünü buldum a değişkenini globalde yazmak yerine for içinde while hemen üstünde yazılmalı

    Aynen öyle.

    for i in categories:
        urller.append(i)
        a = 1
        while a <= 10:
            driver.get(i+'/?p=' + str(a))
            print(driver.current_url)
            sleep(6)
            save = driver.page_source
            soup = BeautifulSoup(save, "html.parser")
            url = soup.find_all("div", {"class":"contributor-wrap cont__info"})
            kategori = soup.find_all("div", {"class":"tag --disabled --size-md --blue topic"})
            for b in url:
                b = b.find("a")["href"]
                urller.append(b)
            for c in kategori:
                c = c.text
                kategoriler.append(c)   
            a+=1;