Селен Python скребок с bs4 зависает в середине пагинации - PullRequest
0 голосов
/ 09 мая 2020

Очистка веб-сайта содержит 67 страниц, и необходимо выполнить разбиение на страницы, но драйвер chrome зависает после страницы 7.

Код выглядит следующим образом:

while url:
        driver.get(url)
        try:       
            products = driver.find_elements_by_css_selector('.prodName')
            prices = driver.find_elements_by_css_selector('.price[id*=retailpricediv]')
            n = driver.find_elements_by_xpath('//li[@class="prodNotes"]')
            pnumber = driver.find_elements_by_xpath('//span[@property="mpn"]')
            print('loading the page')
            time.sleep(15)
            print('loading the products and prices')
            productList = []
            priceList = []
            partnumberList = []
            notesList = []
            for product, price in zip(products,prices):
                productList.append(product.text)
                price = price.text.split('/n')[0].replace('Price: ','')
                priceList.append(price.replace("\nSAVE NOW - See Details",""))

            for note in n:
                notes = note.text
                notesList.append(notes.replace('Notes: ',''))

            for part in pnumber:
                partnumberList.append(part.text)



                    # df = pd.DataFrame({'Product':productList,'Price':priceList})
                    # print(df)
            total = []
            for product, price, partnumber, notes in zip(productList, priceList, partnumberList, notesList):
                data = { 'name': product, 'price': price, 'partnumber' : partnumber, 'notes' : notes }
                total.append(data)


            link = driver.find_element_by_xpath("//li[@class='pageNext']/a")
            url = link.get_attribute("href")

Почему это происходит ? Пожалуйста, помогите.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...