sniffingpickles / Auto-Amazon-Giveaways

Automated Amazon Giveaways using Python3 & Pyppeteer :gift: :snake:
6 stars 8 forks source link

Error after cycling through a handful of Giveaways #14

Closed jacobbentley closed 6 years ago

jacobbentley commented 6 years ago

Traceback (most recent call last): File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 18, in asyncio.get_event_loop().run_until_complete(main()) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 568, in run_until_complete return future.result() File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 16, in main await do_ga_workflow(ga_page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 13, in do_ga_workflow next_page = await ga_bot.iterate_page(page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\lib\giveaway.py", line 151, in iterate_page next_page File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyppeteer\page.py", line 810, in evaluate return await frame.evaluate(pageFunction, args, force_expr=force_expr) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyppeteer\frame_manager.py", line 272, in evaluate pageFunction, args, force_expr=force_expr) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyppeteer\execution_context.py", line 44, in evaluate pageFunction, *args, force_expr=force_expr) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyppeteer\execution_context.py", line 80, in evaluateHandle 'awaitPromise': True, File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyppeteer\connection.py", line 188, in send msg = json.dumps(dict(id=_id, method=method, params=params)) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\json__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "C:\Users\djjak\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 179, in default raise TypeError(f'Object of type {o.class.name} ' TypeError: Object of type ElementHandle is not JSON serializable

jacobbentley commented 6 years ago

Switched to 3.6.x version, same issue:

Traceback (most recent call last): File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 18, in asyncio.get_event_loop().run_until_complete(main()) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 468, in run_until_complete return future.result() File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 16, in main await do_ga_workflow(ga_page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 13, in do_ga_workflow next_page = await ga_bot.iterate_page(page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\lib\giveaway.py", line 151, in iterate_page next_page File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\page.py", line 810, in evaluate return await frame.evaluate(pageFunction, args, force_expr=force_expr) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\frame_manager.py", line 272, in evaluate pageFunction, args, force_expr=force_expr) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\execution_context.py", line 44, in evaluate pageFunction, *args, force_expr=force_expr) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\execution_context.py", line 80, in evaluateHandle 'awaitPromise': True, File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\connection.py", line 188, in send msg = json.dumps(dict(id=_id, method=method, params=params)) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\json__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 180, in default o.class.name) TypeError: Object of type 'ElementHandle' is not JSON serializable

jacobbentley commented 6 years ago

Also hit this error:

Traceback (most recent call last): File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 18, in asyncio.get_event_loop().run_until_complete(main()) File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 468, in run_until_complete return future.result() File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 16, in main await do_ga_workflow(ga_page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\give_it_away_now.py", line 12, in do_ga_workflow await ga_bot.process_giveaways(page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\lib\giveaway.py", line 200, in process_giveaways await self.no_req_giveaways() File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\lib\giveaway.py", line 132, in no_req_giveaways await self.display_ga_result(prize_page) File "C:\Users\djjak\Downloads\Auto-Amazon-Giveaways-master\lib\giveaway.py", line 97, in display_ga_result await prize_page.waitForSelector('.qa-giveaway-result-text') File "C:\Users\djjak\AppData\Local\Programs\Python\Python36\lib\site-packages\pyppeteer\frame_manager.py", line 796, in await yield from self.promise pyppeteer.errors.TimeoutError: Waiting failed: timeout 30000ms exceeds.

Killerherts commented 6 years ago

enable random page selection in give_it_away this fixed the issue for me hope this helps

jacobbentley commented 6 years ago

I'm not seeing a variable for random page selection in give_it_away_now.py

Code here: import asyncio from lib.giveaway import GiveAwayBot

async def main(): ga_bot = GiveAwayBot()

first ga page

ga_page = await ga_bot.login()
# recursive function to repeat bot tasks for every ga page
async def do_ga_workflow(page):
    last_page = await ga_bot.check_for_last_page(page)
    while last_page is False:
        await ga_bot.process_giveaways(page)
        next_page = await ga_bot.iterate_page(page)
        await do_ga_workflow(next_page)
# call recursive function to process all bot tasks.
await do_ga_workflow(ga_page)

asyncio.get_event_loop().run_until_complete(main())

jacobbentley commented 6 years ago

Issue was due to actually having the wrong (old) files. Thank you for pointing me in the right direction, @Killerherts