Code Monkey home page Code Monkey logo

nvidia-notify's Introduction

CHECK PINNED ISSUES - NVIDIA API Is frequently down, this is a known issue and is on NVIDIA's end. If you get timeout issues, best course of action is to wait it out. Check HERE for more info.

Nvidia-Notify

Simple, quick to set up stock notification bot for Nvidia 3080 that I used to get my 3080. Less than 250 lines of code.

Check the Wiki! - We'll post frequently asked questions, tips, and other useful info there.

Requirements

Optional Components

How to set up

  1. Clone/Download the notifier.py file and the icon.ico file and put them in the same folder
  2. Download geckodriver
  3. Open the .env file in a text editor and fill in the variables.
    • Windows users can place geckodriver.exe in the same folder as the script. Otherwise, update WEBDRIVER_PATH
    • refer to the .env file for instructions on specific values.
    • Many features are optional, you can leave them blank if you don't want to use them.
  4. pip install dependencies
    • pip install -r requirements.txt or python -m pip install -r requirements.txt
    • If running windows, use win-requirements.txt instead.
    • On some Linux/Mac systems, you may need to use python3 and pip3 instead of python and pip, respectively.
  5. You can open notifier.py in a text editor and modify the list of pages that get scanned.

How to Run

python notifier.py

Note that on some linux and mac systems, you may have to use the following instead:

python3 notifier.py

Testing if Notifications Work (Twilio/Discord)

python notifier.py test

replace 'python' with 'python3' if that is how your system is configured

MacOS Python3 Info

MacOS typically has Python 2 installed on the path as python by default. If you do not have Python 3 on your system, the easiest way to install is to get it from HomeBrew (https://brew.sh/)

Once you have brew installed, you can install Python 3 by running this:

brew install python3

When installed in this way, you will normally need to run it as python3 instead of python

python3 notifier.py

You will also need to install your pip dependencies with pip3 instead of pip like so:

pip3 install -r requirements.txt
MacOS Gecko Driver Security

The first time you run this script on a mac, the system will prevent you from using the gecko driver. To allow this, open System Preferences > Security and Privacy and under the general tab, click the button to allow geckodriver to be run. You will need to run the script at least once before you can do this. The first time you run the script after allowing geckodriver the script will crash again, but it will not crash after that.

Configuring the websites to check

If you are in the mood you can change or add your own websites to check stock for.

They are defined in a JSON file, named sites.json. It includes several of the most popular sites and searches.

The site.json file can be found here.

Field Value Description
url valid url The url of the site, including the query string params specific to the site for narrowing results, specifying a product number, specific filtering options, etc...
api valid url The api url to use, this is specific to Nvidia. The method GET_API is required
keyword text The keyword that you're looking for in the html of the website
alert true or false If true, it will alert when the keyword is found in the html. If false, it will alert if the keyword is NOT found in the html
method GET_SELENIUM, GET_URLLIB, or GET_API Which method is used to fetch data from the site.
name text A nickname for the alert to use.
enabled true or false Whether the site will be checked. Useful for example, when testing your addition, and disabling the rest so you can quickly see the results.

An example:

  {
    "url": "https://www.newegg.com/p/pl?d=rtx+3080&N=100007709%20601357247",
    "keyword": "Add to cart",
    "alert": true,
    "method": "GET_URLLIB",
    "name": "Newegg 3080",
    "enabled": true
  }

Feel free to submit any PRs or issues!!

nvidia-notify's People

Contributors

brydon avatar erjanmx avatar guba-jeckerman avatar jeckerman avatar kosyne avatar levytsroman avatar rexprograms avatar samuelm2 avatar steffana avatar yueclipse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvidia-notify's Issues

Nvidia API URL no longer working

The Nvidia API URL is timing out and not working.

Hard to tell if they moved it or is just temporarily down?

Checking Nvidia 3080...
	Connection failed...
	HTTPSConnectionPool(host='api-prod.nvidia.com', port=443): Read timed out. (read timeout=5)

Looks like on their own site they are using the same URL and the call is timing out there as well. So likely an Nvidia problem.

Getting a couple of errors, new to python so this may be me

this is the error im getting when running the notifier.py

c:\testbot>python notifier.py test
Enabling Selenium... Traceback (most recent call last):
  File "C:\Users\rowan\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\rowan\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\rowan\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\testbot\notifier.py", line 52, in <module>
    driver = webdriver.Firefox(options=options, executable_path=WEBDRIVER_PATH)
  File "C:\Users\rowan\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Users\rowan\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver.exe' executable needs to be in PATH

I have set the directory of geckodriver in .env file as follows

WEBDRIVER_PATH="C:\testbot\geckodriver.exe"

Connection failed

After setup as instructions, as I run the script, the output for each website is "Connection failed... HTTPSConnectionPool(host='api-prod.nvidia.com', port=443): Read timed out. (read timeout=5)" or "<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>"

On Mac, python3 /path/notifier.py returns error.

With python3 /Users/[user]/Downloads/Nvidia-Notify-master/notifier.py

terminal returns

Traceback (most recent call last):
  File "/Users/brandonli/Downloads/Nvidia-Notify-master/notifier.py", line 40, in <module>
    with open('sites.json', 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'sites.json'

Is there a fix for it? Thanks.

Edit: I do have the file sites.json in the Nvidia-Notify directory. The folder was git cloned.

Nvidia API 504 Error

"Connection failed...
HTTPSConnectionPool(host='api-prod.nvidia.com', port=443): Read timed out. (read timeout=5)"

B & H 403 Forbidden

I tried to use Selenium and it does not error out, but when I created a test version with a link it never alerted. Any idea on either a good URL to use with a good method?

Enable detecting "See buying options" on Amazon

Amazon only shows see buying options on the 3080/3090 page and not directly add to cart therefore the bot doesn't detect it. Can this be addressed? I saved the html of the Amazon page when the see buying options showed can provide if it helps. I changed the detection string to "See buying options" in the code but then it detects everything. Need something more specific to the button when it is actually showing on the page not source of html

image

More descriptive readme

I'd like it to have better instructions for setting up so someone without any technical experience could set it up more easily

Ability to test twilio/discord integrations

Currently there's no way to verify if everything is set up correctly. Create an option, config, secondary script, or whatever it may be, that allows users to perform a test run of the notification options as configured in the .env file.

not an issue but a suggestion

Is there any way to scan multiple sites/urls at once? Ive done some googling and came across asyncio and aiohttp, but Ive never dealt with python and I dont fully understand how to implement this

Problem

File "notifier.py", line 41, in
sites = json.load(f)
File "/usr/lib/python3.8/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 26 column 3 (char 825)

change bestbuy link

current bestbuy link finds other things with 3080 in name... simply adding geforce is not enough as it finds the MSI laptop with 3080 graphics card.. i want a PC one..

if you want the laptop... its available now actually..
https://www.bestbuy.com/site/msi-gs66-15-6-300hz-gaming-laptop-intel-core-i7-nvidia-geforce-rtx-3080-1tb-ssd-32gb-memory-black/6448275.p?skuId=6448275

but for PC 3080 I put this for bestbuy url in sites.json:

"url": "https://www.bestbuy.com/site/searchpage.jsp?_dyncharset=UTF-8&id=pcat17071&iht=y&keys=keys&ks=960&list=n&qp=chipsetmanufacture_facet%3DChipset%20Manufacture~NVIDIA&sc=Global&st=3080+geforce"

Issues with Best Buy over long periods of time

Best Buy initially works, but over time it runs into issues. Probably something to do with Selenium. It worked before we used NVIDIA API I believe, so it may have issues with multiple libraries seeking connections at the same time, connections not being closed/cleared/refreshed properly, or I could be completely off base and it could be something else.

Any help is appreciated on this one.

Starting search 3 at 19:16:56
        Checking Nvidia 3080...
        Checking Nvidia 3090...
        Checking EVGA 3080...
        Checking Newegg 3080...
        Checking BandH 3080...
        Checking BestBuy 3080...
        Checking Amazon 3080...
Starting search 4 at 19:17:21
        Checking Nvidia 3080...
        Checking Nvidia 3090...
        Checking EVGA 3080...
        Checking Newegg 3080...
        Checking BandH 3080...
        Checking BestBuy 3080...
                Connection failed...
                Message: Browsing context has been discarded

        Checking Amazon 3080...
Starting search 5 at 19:17:48
        Checking Nvidia 3080...
        Checking Nvidia 3090...
        Checking EVGA 3080...
        Checking Newegg 3080...
        Checking BandH 3080...
        Checking BestBuy 3080...
                Connection failed...
                Message: Failed to decode response from marionette

        Checking Amazon 3080...
Starting search 6 at 19:18:08
        Checking Nvidia 3080...
        Checking Nvidia 3090...
        Checking EVGA 3080...
        Checking Newegg 3080...
        Checking BandH 3080...
        Checking BestBuy 3080...
                Connection failed...
                Message: Tried to run command without establishing a connection

        Checking Amazon 3080...
Starting search 7 at 19:18:21
        Checking Nvidia 3080...
        Checking Nvidia 3090...
        Checking EVGA 3080...
        Checking Newegg 3080...
        Checking BandH 3080...
        Checking BestBuy 3080...
                Connection failed...
                Message: Tried to run command without establishing a connection

Question about multiple keywords?

Unfortunately Canada always seems to have wonky versions of everything ["available online","online only"], is it possible to have two keywords in a JSON entry?
Best buy for example either has one of the two and "available" will pick up false positives,

Edit: Still had false positives with those strings, found <span data-automation="store-availability-checkmark" aria-hidden="true"> which would probably work, it doesn't seem to find it though. Is it easy to do something where I can add another search method without breaking the entire thing?:

keyword = site.get('keyword')
                alert_on_found = site.get('alert')
                index = html.upper().find(keyword.upper())
                if alert_on_found and index != -1:
                    alert(site)
                elif not alert_on_found and index == -1:
                    alert(site)

Two minor issues

Nice update! Noticed two minor issues:

Nvidia-Notify/notifier.py

Lines 105 to 124 in a6dfa0a

sms_notification()
discord_notification(product, url)
time.sleep(ALERT_DELAY)
def os_notification(title, text):
if platform == PLT_MAC:
system("""
osascript -e 'display notification "{}" with title "{}"'
""".format(text, title))
system('afplay /System/Library/Sounds/Glass.aiff')
system('say "{}"'.format(title))
elif platform == PLT_WIN:
toast.show_toast(title, text, duration=5, icon_path="icon.ico")
elif platform == PLT_LIN:
# Feel free to add something here :)
pass
def sms_notification():

Lines 105 and 124, sms_notification() need the url parameter

Line 107, remove time.

It's great seeing all the attention it's getting since your reddit post yesterday, great work

Using the cod without firefox??

Hello, is there any way that I can use this code without firefox? For example, I cannot install firefox to my computer and trying to use this code with chrome or explorer or edge. Is it possible? If it is can you please tell me how? Thanks.

Issue with dependency

Does this still work? Going through your steps i get the follow error when running

sudo python3 notifier.py test

Traceback (most recent call last): File "notifier.py", line 12, in <module> from dotenv import load_dotenv ModuleNotFoundError: No module named 'dotenv'

I do not know enough about python but I have installed all of the requirements like shown in the steps and it does apparently not know where to find the dotenv module.

URLLIB vs Requests

Why use URLLIB instead of requests library? Is it just a matter of personal preference or for this application does it have advantages?

client not defined?

C:\Nvidia-Notify-master>python notifier.py test
Enabling Selenium... Done!
Running on Windows
BestBuy 3080 IN STOCK
https://www.bestbuy.com/site/searchpage.jsp?st=3080
Starting search 0 at 13:54:03
Checking BestBuy 3080...
BestBuy 3080 IN STOCK
https://www.bestbuy.com/site/searchpage.jsp?st=3080
Traceback (most recent call last):
File "C:\Nvidia-Notify-master\notifier.py", line 214, in
main()
File "C:\Nvidia-Notify-master\notifier.py", line 204, in main
alert(site)
File "C:\Nvidia-Notify-master\notifier.py", line 85, in alert
sms_notification(site.get('url'))
File "C:\Nvidia-Notify-master\notifier.py", line 110, in sms_notification
client.messages.create(to=TWILIO_TO_NUM, from_=TWILIO_FROM_NUM, body=url)
NameError: name 'client' is not defined

Twilio Account setup? and other question

Hi, I have trial Twilio Account created, now what exactly I need to edit in notifier.py to enable it?
Can you please give me a example how it should look?

I enabled
USE_TWILIO = True

TWILIO_TO_NUM = 1111111111111 < what is the difference between TO and FROM, I only have one number?
TWILIO_FROM_NUM = < what is the difference between TO and FROM, I only have one number?
TWILIO_SID = I see this information on twilio page, but how exactly it should look here?
TWILIO_AUTH = I see this information on twilio page, but how exactly it should look here?

Or anything else is needed to be modified?

Second (not sure if) issue
I changed URL keyword to my locale which is cs-cz, did I need to edit also something on second URL api-prod?
I don't get any error for now, but I'm not sure if it's checking availability for my country (Czech Republic)
url_keywords = {
"https://www.nvidia.com/cs-cz/geforce/graphics-cards/30-series/rtx-3080/": ("https://api-prod.nvidia.com/direct-sales-shop/DR/products/en_us/USD/5438481700", False, GET_API, 'Nvidia 3080', ),
"https://www.nvidia.com/cs-cz/geforce/graphics-cards/30-series/rtx-3090/": ("https://api-prod.nvidia.com/direct-sales-shop/DR/products/en_us/USD/5438481600,5443202600", False, GET_API, 'Nvidia 3090', ),

nvidia website gives false positives

recently the nvidia website started giving false positives. I haven't had time to figure out a way around these false positives, so if someone has time to figure it out and wants to submit a PR that'd be great

Not an issue - question regarding code

Not an issue, hope it's okay to ask here, i'm beginner in python but can someone please explain what is the purpose of this code from notifier.py starting at line 205? i understand the first if statement but why the second one does the same thing (send alert)?:

if alert_on_found and index != -1:
    alert(site)
elif not alert_on_found and index == -1:
    alert(site)

normalized webdriver path on mac fails if path is ./

on macif you put the geckodriver file in the working directory of this repo and set your .env file to have
WEBDRIVER_PATH = "./geckodriver"

when the path gets normalized with path.normpath(), it throws the following error when trying to run:

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Removing the normalizing function fixes this. This may just be a bug with the selenium module, but it makes the program not run on mac unless you specify an absolute path for the webdriver.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.