Hari-Nagarajan / fairgame

Tool to help us buy hard to find items.
GNU General Public License v3.0
2.44k stars 804 forks source link

Amazon - Unicode cp932 codec can't encode character '\xfc' #213

Open keinh opened 4 years ago

keinh commented 4 years ago

System: win10 pro I setup the amazon bot to run and short after start I get this

INFO: "2020-10-02 14:38:29,852 - Initializing notification handlers
INFO: "2020-10-02 14:38:29,853 - Enabled Handlers: ['Audio']
INFO: "2020-10-02 14:38:29,853 - Initializing notification handlers
INFO: "2020-10-02 14:38:29,854 - Enabled Handlers: ['Audio']
{'BASE_URL': 'https://www.amazon.com/', 'CART_URL': 'https://www.amazon.com/gp/aws/cart/add.html'}
INFO: "2020-10-02 14:38:35,755 - Waiting for home page.
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Kein\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
UnicodeEncodeError: 'cp932' codec can't encode character '\xfc' in position 297: illegal multibyte sequence
Call stack:
  File "app.py", line 5, in <module>
    cli.main()
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\cli\cli.py", line 20, in decorator
    func(*args, **kwargs)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\cli\cli.py", line 67, in amazon
    amzn_obj = Amazon(headless=headless)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 99, in __init__
    self.check_if_captcha(self.wait_for_pages, HOME_PAGE_TITLES)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 209, in check_if_captcha
    func(args)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 227, in wait_for_pages
    log.debug(f"wait_for_pages({page_titles}, {t})")
Message: "wait_for_pages(['Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more', 'Amazon.co.uk: Low Prices in Electronics, Books, Sports Equipment & more', 'Amazon.de: Low Prices in Electronics, Books, Sports Equipment & more', 'Amazon.de: G\xfcnstige Preise f\xfcr Elektronik & Foto, Filme, Musik, B\xfccher, Games, Spielzeug & mehr', 'Amazon.es: compra online de electr\xf3nica, libros, deporte, hogar, moda y mucho m\xe1s.', 'Amazon.de: G\xfcnstige Preise f\xfcr Elektronik & Foto, Filme, Musik, B\xfccher, Games, Spielzeug & mehr', 'Amazon.fr : livres, DVD, jeux vid\xe9o, musique, high-tech, informatique, jouets, v\xeatements, chaussures, sport, bricolage, maison, beaut\xe9, pu\xe9riculture, \xe9picerie et plus encore !'], 30)"
Arguments: ()
INFO: "2020-10-02 14:38:36,352 - Already logged in
INFO: "2020-10-02 14:38:36,352 - Checking stock for items.
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\Kein\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
UnicodeEncodeError: 'cp932' codec can't encode character '\xe4' in position 114: illegal multibyte sequence
Call stack:
  File "app.py", line 5, in <module>
    cli.main()
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Kein\.virtualenvs\nvidia-bot-nnqj94KR\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\cli\cli.py", line 20, in decorator
    func(*args, **kwargs)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\cli\cli.py", line 68, in amazon
    amzn_obj.run_item(test=test)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 146, in run_item
    while not self.something_in_stock():
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 163, in something_in_stock
    self.check_if_captcha(self.wait_for_pages, ADD_TO_CART_TITLES)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 209, in check_if_captcha
    func(args)
  File "E:\Chrome Downloads\nvidia-bot-master\nvidia-bot\stores\amazon.py", line 227, in wait_for_pages
    log.debug(f"wait_for_pages({page_titles}, {t})")
Message: "wait_for_pages(['Amazon.com: Please Confirm Your Action', 'Amazon.de: Bitte best\xe4tigen Sie Ihre Aktion', 'Amazon.de: Please Confirm Your Action', 'Amazon.es: confirma tu acci\xf3n', 'Amazon.com\\xa0: Veuillez confirmer votre action'], 30)"

The bot however doesn't crash and keeps refreshing the page, printing the same 2nd stack trace every time. Is this an issue with multi language support?

vivektamore commented 4 years ago

https://github.com/phoboslab/jsmpeg-vnc/pull/70/commits/105998600c0ae2ca6b8920194f5698c486008db7

keinh commented 4 years ago

I was able to stop the errors by deleting the strings associated with other stores in amazon.py. Not sure if its something to do with windows language settings but I only have regular english installed.

Hari-Nagarajan commented 4 years ago

Yeah this one is a real headscratcher