zdrouse / Auto-Amazon-Giveaways

Automated Amazon Giveaways using Python3 & Pyppeteer :gift: :snake:
56 stars 31 forks source link

Hangs after launching chromium #15

Open dziban303 opened 6 years ago

dziban303 commented 6 years ago

After launching the script, it asks for Amazon username and password, then launches chromium. At that point, nothing else happens. It doesn't open anything in chromium.

2018-07-05_15-51-36

Meanwhile, python.exe consumes a CPU core. 2018-07-05_15-51-59

Stopping the process yields the following: cmd_2018-07-05_15-58-27

Any ideas?

sniffingpickles commented 6 years ago

You have to install 3.6.6, looks like you installed latest 3.7:

https://www.python.org/downloads/release/python-366/

dziban303 commented 6 years ago

Doh. Forgot to fix the PATH variable. Thanks, now the script it running. It went through a few giveaways, then crashed. cmd_2018-07-09_18-01-09

sniffingpickles commented 6 years ago

It's unable to grab the next page URL; I'm working on fix for that right now (shhh dont' tell @zdrouse )

dziban303 commented 6 years ago

That would be great if you could fix it. It's a bit beyond me, I'm afraid.

It'd be nice if it would accept username and password as command line variables, or store them in a cfg file.

sniffingpickles commented 6 years ago

This is my 2nd time ever messing around with python, honestly. I normally outsource it.

But i'm almost positive the xpath is incorrect (maybe something updated in the recent months), and it doesn't know how to use the "navigate to" function in that iteration function.

Lastly, I'm pretty sure we can just save the variables somewhere. I'll look at making a config line

sniffingpickles commented 6 years ago

So, to make it so you don't have to type login over and over, go to like 47/48 on giveaway.py

image

sniffingpickles commented 6 years ago

Updated and fixed the loop problem:

https://github.com/sniffingpickles/Auto-Amazon-Giveaways

dziban303 commented 6 years ago

Works for a bit, and then:

cmd_2018-07-10_13-00-18

sniffingpickles commented 6 years ago

I haven't figured out why pyppeteer likes to get hungup on tabs opening/closing

So i made a quick "ghetto" fix:

Create a file called "loop.py" (in same directory as give_it_away_now.py)

put this in it:

from subprocess import Popen
import sys

filename = sys.argv[1]
while True:
    print("\nStarting " + filename)
    p = Popen("python " + filename, shell=True)
    p.wait()

Now start giveaway bot with

python loop.py "give_it_away_now.py"

Basically this is a way to make sure the process restarts. I'm working on a way to log the last page it gets "stuck" on, so if it restarts, it just continues.

dziban303 commented 6 years ago

There are a lot of pages, right? So upon restart, what about creating a random number in loop.py and starting at that page? That would ensure it's not doing the same 20 giveaways over and over.

sniffingpickles commented 6 years ago

Sure,

Add this to the top of the page:

Line: 13 RANDOM_PAGE = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] Add more numbers if you'd like

Then change the giveaway url string to (on line 23'ish, can't say since mine is edited a lot) await login_page.goto('https://www.amazon.com/ga/giveaways?pageId=' + str(numpy.random.choice(RANDOM_PAGE)))

dziban303 commented 6 years ago

I see you added support for YT videos on your fork. Since the tab doesn't have to be in the foreground for the 30s timer to work, could the bot move on to the next giveaway and come back to the video giveaway tab afterwards? That way the bot won't get stuck only doing 2 giveaways per minute.

It's actually less than 2 per minute, because the bot's 30 second timer only starts several seconds after the tab is opened; the Continue button activates well before the bot clicks it.

Anyway you've got the "Issues" section disabled on your fork, you might consider turning it on (in repository settings).

Thanks for everything!

sniffingpickles commented 6 years ago

I've actually rebuilt a ton of features, just struggling time to upload them.

If you multi-thread the chrome process, it times out often. I tried :(

I added all video support, a database for remembering giveaways visited, and everytype of giveaway completed. I do the amazon video type by injecting javascript into the page lol

sniffingpickles commented 6 years ago

updated my repo, added the features above, and enabled issues tracker