yosh1 / amazon-automation

Script to make an automatic purchase on Amazon
MIT License
81 stars 28 forks source link

english branch using amazon.com ? #10

Open cloud-aware opened 3 years ago

cloud-aware commented 3 years ago

Hi, can you make a branch that works for amazon.com (english) ?

cloud-aware commented 3 years ago

and would it be as simple as changing line 40 in main.py to be:

shop = shop.split('Sold')[0].split('This product is,')[1]

druyang commented 3 years ago

There are a few more changes, I am currently making some changes to the script in my own branch

cloud-aware commented 3 years ago

@druyang, excellent, was trying to use this to snag the xbox series x :-D

druyang commented 3 years ago

@Skullduggeryism I hit a snag with getting selenium to work on my system, going to try later. here's the latest branch, see if it works for you:

https://github.com/druyang/amazon-PS5-automation/tree/english-qol-updates

yosh1 commented 3 years ago

@Skullduggeryism @druyang

Sorry, I didn't notice your comment. Please PR your branch to my branch. I can review your code and incorporate it.

NewMKE commented 3 years ago

@yosh1 @druyang Hi guys, I have a question here. I used the English version @druyang has attached here. I am pretty sure I have installed everything correctly. But when I run the main.py file, it just opens the item URL but it won't sign in to amazon automatically. And it won't proceed to the checkout page as well. Could you guys help me with it? Thank you so much.

cloud-aware commented 3 years ago

@yosh1 @druyang Hi guys, I have a question here. I used the English version @druyang has attached here. I am pretty sure I have installed everything correctly. But when I run the main.py file, it just opens the item URL but it won't sign in to amazon automatically. And it won't proceed to the checkout page as well. Could you guys help me with it? Thank you so much.

Make sure you have 2FA (two factor authentication) turned off on your Amazon account, and make sure you have copied the ".env.sample" file to ".env" and made the appropriate changes to that file.

Edit: also, I would use the default branch, as I believe it's newer than the update branch

druyang commented 3 years ago

@yosh1 @druyang Hi guys, I have a question here. I used the English version @druyang has attached here. I am pretty sure I have installed everything correctly. But when I run the main.py file, it just opens the item URL but it won't sign in to amazon automatically. And it won't proceed to the checkout page as well. Could you guys help me with it? Thank you so much.

This sounds like the environment variables weren't moved in correctly. Could you also paste the logs of the program? When you get the sign in failure + failure to checkout?

NewMKE commented 3 years ago

Thank you so much for replying! I just checked I do not have the 2FA on my Amazon account. And I did copy the ".env.sample" file to ".env" file with appropriate changes(my Amazon email and password). So when I run the program, it pops up a window like this: Screenshot from 2020-12-15 21-42-19 The top right asks me to sign in and then the program does nothing and kinda just stays where it is. When I close this window and wait for about 1 min. My terminal gives me this:

Traceback (most recent call last): File "main.py", line 44, in raise Exception("not Amazon.") Exception: not Amazon.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 50, in b.refresh() File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 831, in refresh self.execute(Command.REFRESH) File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: chrome not reachable (Session info: chrome=87.0.4280.66)

druyang commented 3 years ago

It won't log in unless the item is instock and by Amazon (hence the first exception).

Second exception looks a little weird. What version of selenium + chrome + driver do you have? Chrome and your driver should match versions

NewMKE commented 3 years ago

I have tried something that is in stock on Amazon. The program acts the same without the first exception. For selenium, I used version 3.141.0, which is written in the "requirements.txt" by @yosh1 I check my chrome version: Version 87.0.4280.66 (Official Build) (64-bit) And when I type “chromedriver" in the terminal, it shows "Starting ChromeDriver 87.0.4280.88“ The only difference is the last two digits, 66 and 88. Does this make a difference? But the "88" is what I download from the chromedriver website and I cannot find "66" version there. Thank you.

NewMKE commented 3 years ago

Guys, I have played with my code several times and I found out if I comment out line 38 to line 44, this code actually works. So I basically just comment out the part it detects if the merchant is from Amazon. But when I add these lines back, it gives me an error: Traceback (most recent call last): File "main_copy.py", line 38, in shop = b.find_element_by_id('merchant-info').text File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in find_element_by_id return self.findelement(by=By.ID, value=id) File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/user/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="merchant-info"]"} (Session info: chrome=87.0.4280.66)

I think it has to do with the "find_element_by_id('merchant-info').text" part. My machine just doesn't like it. So how should I change this part to make it work? @yosh1 @druyang. Thank you