mark-thompson / whole-foods-deliverance

[Availability notifications, auto-checkout, slot preferences, cart tracking] for Whole Foods / Amazon Fresh
MIT License
53 stars 12 forks source link

ARM alternative to chromedriver-binary? #18

Open rgov opened 4 years ago

rgov commented 4 years ago

The chromedriver-binary package only includes an x86_64 binary, so this can't be run on a Raspberry Pi or other ARM system.

/usr/local/lib/python3.6/dist-packages/chromedriver_binary/chromedriver: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=59cd88aeed037aaa10f05efbd725908f3f982ea3, stripped

Is there an alternative?

rgov commented 4 years ago

Apparently yes: https://stackoverflow.com/questions/38732822/compile-chromedriver-on-arm

I was able to just use apt install chromium-driver and then presumably the resulting tool is already in $PATH so it's not necessary to do anything else.

mark-thompson commented 4 years ago

Interesting. Does this fail at any stage using chromedriver-binary as it is in the repo now? Specifically, does importation append the wrong binary to the front of $PATH?

rgov commented 4 years ago

Well if you install chromedriver-binary it will give you a chromedriver that cannot be executed so as soon as the code calls this tool, it will fail.

mark-thompson commented 4 years ago

Right, totally get that, but does the code in this repo work as-is, assuming you've installed chromium-driver via apt? Or does the importation of chromedriver-binary alter PATH such that it tries to use the x86 binary and fails?

rgov commented 4 years ago

Ah, right. chromedriver-binary prefixes PATH so it would seem that the kernel will attempt to launch the x86 binary before the installed package.

I haven't tried yet because this doesn't support logging into Amazon, it expects Chrome is already logged in, so I wasn't able to use it in the headless manner I expected.

mark-thompson commented 4 years ago

Yeah, I thought that might be the case. A conditional import based on platform.machine() may be a viable option, though that doesn't help with the headless bit.

I had thought about automating the login process - sending values to elements is easy enough, but things get complicated when you've either enabled, or Amazon forces OTP.

rgov commented 4 years ago

Can I just copy cookies from a logged in browser on another machine?

eoprede commented 4 years ago

I can confirm that the chromedriver.exe placed in the folder with the script is getting executed before chromedriver-binary. So it should be easy to override it with whatever other driver one may want.

mark-thompson commented 4 years ago

@rgov I looked into that initially, but there are various hoops one has to jump through to programmatically access profile protected storage (cookes, localStorage, etc.). On OSX anyway, it requires access to the Chrome Safe Storage keychain item.

You may be able to do this manually, however, or by running a Selenium instance on the authenticated machine, using your authenticated chrome profile (via the user-data-dir argument to ChromeOptions), then using something like utils.store_session_data from this repo.