Closed benengx closed 4 years ago
can you try git pull
, also I am not sure how the code can cause that error, there is a catch for AttributeError. I'm not sure how to debug this.
I will try this, thanks! I realized that there were additional messages after the AttributeError, so I'm including all of them here in case they are useful. Thanks again for your help! Best,
Ben
Traceback (most recent call last):
File "C:\ software\wholefoods\Whole-Foods-Delivery-Slot-master\whole_foods_delivery_autobuy_windows.py", line 103, in getWFSlot
if no_slot_pattern == soup.find('h4', class_ ='a-alert-heading').text:
AttributeError: 'NoneType' object has no attribute 'text'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\software\wholefoods\Whole-Foods-Delivery-Slot-master\whole_foods_delivery_autobuy_windows.py", line 23, in autoCheckout
slot_select_button =
driver.find_element_by_xpath('/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[1]/div[4]/div[2]/div/div[3]/div/div/ul/li/span/span/div/div[2]/span/span/button')
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[1]/div[4]/div[2]/div/div[3]/div/div/ul/li/span/span/div/div[2]/span/span/button"}
(Session info: chrome=81.0.4044.92)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\software\wholefoods\Whole-Foods-Delivery-Slot-master\whole_foods_delivery_autobuy_windows.py",
line 129, in
getWFSlot('
https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1 ')
File "C:\ software\wholefoods\Whole-Foods-Delivery-Slot-master\whole_foods_delivery_autobuy_windows.py", line 113, in getWFSlot
autoCheckout(driver)
File "C:\ software\wholefoods\Whole-Foods-Delivery-Slot-master\whole_foods_delivery_autobuy_windows.py", line 27, in autoCheckout
slot_select_button =
driver.find_element_by_xpath('/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[1]/div[4]/div[2]/div/div[4]/div/div/ul/li/span/span/div/div[2]/span/span/button')
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Ben\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[1]/div[4]/div[2]/div/div[4]/div/div/ul/li/span/span/div/div[2]/span/span/button"}
(Session info: chrome=81.0.4044.92)
On Sat, Apr 11, 2020 at 3:06 PM Pooja Ahuja notifications@github.com wrote:
can you try git pull, also I am not sure how the code can cause that error, there is a catch for AttributeError. I'm not sure how to debug this.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pcomputo/Whole-Foods-Delivery-Slot/issues/40#issuecomment-612492385, or unsubscribe https://github.com/notifications/unsubscribe-auth/AINLNZJU7PGEI3CX4PFDR3LRMC5UJANCNFSM4MGAGPFQ .
there are latest changes up for this. Can you please test.
from selenium import webdriver from bs4 import BeautifulSoup import pandas as pd driver = webdriver.Chrome("D:/chromedriver") products=[] #List to store name of the product prices=[] #List to store price of the product Descriptions=[] #List to store rating of the product driver.get("https://www.nike.com/w/womens-lifestyle-shoes-13jrmz5e1x6zy7ok") content = driver.page_source soup = BeautifulSoup(content) for a in soup.find_all('a',href=True, attrs={'class':'product-cardlink-overlay'}): name = a.find('div', attrs={'class':'product-cardtitle'}) price=a.find('div', attrs={'class':'product-cardprice'}) products.append(name.text) prices.append(price.text) Descriptions=a.find('li', attrs={'class':'product-cardsubtitle'})
df = pd.DataFrame({'Product Name':products,'Price':prices, 'Description' :Descriptions})
df.to_csv('scraping .csv', index=False, encoding='utf-8')
Error products.append(name.text) AttributeError: 'NoneType' object has no attribute 'text'
Hi, first off, thank you very much for writing this! I am trying to get the windows autobuy script to work, and indeed it seemed to have found an open slot (printed "SLOTS OPEN!"). But then I got the following error:
Any help would be appreciated! Best,
Ben