Automate checking whether the Pinecil is still in stock
#1
Big Grin 
Here is a quick way to see whether the Pinecil gets back in stock.
I've been meaning to get one, but it is out of stock. To automate my stalking of pine's website, i've written this python script and thought that I could share it if someone thinks that it's neat:
Code:
import requests as r
from tkinter import messagebox as m
import tkinter as tk
import os

url = "https://pine64.com/product/pinecil-smart-mini-portable-soldering-iron/?v=0446c16e2e66"

#don't show a main window
root = tk.Tk()
root.withdraw()

response = r.get(url)

source = response.text

startIndex = source.find("<title>")
endIndex = source.find("</title>")

if (startIndex == -1) or (endIndex == -1):
    m.showerror(title="could not check pine64.com", message="please check your internet connection")
    quit()

if("[Out of Stock]" in source[startIndex:endIndex]):
    print(source[startIndex:endIndex])
    m.showinfo(title="OUT OF STOCK", message="the Pinecil is stil out of stock, unfortunately")
else:
    choice = m.askquestion(title="IN STOCK", message="THE PINECIL IS BACK\nGo to the store?")
    if choice == 'yes':
        os.system("firefox "+url)
This will show the following when executed
https://ibb.co/XzLBd1P
https://ibb.co/XCcJb9D

the only thing left then is to add a menu item with the command:
Code:
python ~/checkPinecil.py
(replace "~/checkPinecil" with the path to your saved file)

Then you can easily check whether it is available Smile

P.s. I am aware of how useless this is, but I was bored and this is the result.

Best Regards, Julius
  Reply
#2
haha! this is awesome. i'd happily alter that and point people to it for the pbp, tab, and phone, too Big Grin
  Reply
#3
Hi. I'm not a python programmer. But I made a couple of small changes for Linux.

up the top put the following for direct execution. Assuming that's where you can find your python
Code:
#!/usr/bin/python3

and this down the bottom. replacing firefox with xdg-open to be a little more generic:
Code:
os.system("xdg-open "+url)

In my case it opens a tab in chromium because it's my default browser.

don't forget to chmod +x checkPinecil.py if you want to run the file directly.

e: Thanks again for posting. I just got the basics of your program running in MicroPython on an eap32. So I now have the basis of a standalone in-stock alert.
  Reply
#4
(02-01-2021, 08:45 PM)ImmortanJoe Wrote:
Code:
#!/usr/bin/python3

Code:
os.system("xdg-open "+url)
Those are good changes, I didn't really give machine independence a lot of thought when I wrote it.
I'm glad that this could serve as a basis, your project sounds really cool
  Reply
#5
Any rumor as to when the next will go on sale?
  Reply
#6
(01-27-2021, 02:15 PM)Julius_GU Wrote: Here is a quick way to see whether the Pinecil gets back in stock.
I've been meaning to get one, but it is out of stock. To automate my stalking of pine's website, i've written this python script and thought that I could share it if someone thinks that it's neat:
Code:
import requests as r
from tkinter import messagebox as m
import tkinter as tk
import os

url = "https://pine64.com/product/pinecil-smart-mini-portable-soldering-iron/?v=0446c16e2e66"

#don't show a main window
root = tk.Tk()
root.withdraw()

response = r.get(url)

source = response.text

startIndex = source.find("<title>")
endIndex = source.find("</title>")

if (startIndex == -1) or (endIndex == -1):
    m.showerror(title="could not check pine64.com", message="please check your internet connection")
    quit()

if("[Out of Stock]" in source[startIndex:endIndex]):
    print(source[startIndex:endIndex])
    m.showinfo(title="OUT OF STOCK", message="the Pinecil is stil out of stock, unfortunately")
else:
    choice = m.askquestion(title="IN STOCK", message="THE PINECIL IS BACK\nGo to the store?")
    if choice == 'yes':
        os.system("firefox "+url)
This will show the following when executed
https://ibb.co/XzLBd1P
https://ibb.co/XCcJb9D

the only thing left then is to add a menu item with the command:
Code:
python ~/checkPinecil.py
(replace "~/checkPinecil" with the path to your saved file)

Then you can easily check whether it is available Smile

P.s. I am aware of how useless this is, but I was bored and this is the result.

Best Regards, Julius
updated it so it also knows if something will be back soon also any browser will work now 

Code:
import webbrowser as web
import requests as r
from tkinter import messagebox as m
import tkinter as tk
import os

url = "https://pine64.com/product/pinecil-smart-mini-portable-soldering-iron/?v=0446c16e2e66"

root = tk.Tk()
root.withdraw()

response = r.get(url)

source = response.text

startIndex = source.find("<title>")
endIndex = source.find("</title>")

if (startIndex == -1) or (endIndex == -1):
    m.showerror(title="could not check pine64.com", message="please check your internet connection")
    quit()

if("[Out of Stock]" in source[startIndex:endIndex]):
    print(source[startIndex:endIndex])
    m.showinfo(title="OUT OF STOCK", message="the Pinecil is stil out of stock, unfortunately")
elif("[Schedule back in stock " in source[startIndex:endIndex]):
    print(source[startIndex:endIndex])
    m.showinfo(title="OUT OF STOCK", message="the Pinecil is scheduled to be back in stock")
else:
    choice = m.askquestion(title="IN STOCK", message="THE PINECIL IS BACK\nGo to the store?")
    if choice == 'yes':
        web.open(url, new=0, autoraise=True)
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pinepower suitable for an s23 (and a pinecil) its_lieseeeee 0 120 12-09-2024, 01:41 PM
Last Post: its_lieseeeee
  Pinecil constantly cutting out WroughtIron 0 164 11-15-2024, 10:37 AM
Last Post: WroughtIron
  Help with Pinecil saranelson 1 223 11-09-2024, 02:19 PM
Last Post: biketool
  pinecil v2 reverse polarity issue adamsk1952 0 403 09-12-2024, 07:54 AM
Last Post: adamsk1952
Sad Pinecil V2 screw broken! Carol8 1 285 09-09-2024, 08:44 AM
Last Post: Carol8
  Pinecil on Amazon? WEF 5 1,878 09-05-2024, 08:23 AM
Last Post: Jeb
Question Pinecil v2 power cycles at higher voltages? clemon79 3 2,321 08-10-2024, 05:47 AM
Last Post: RevAngel
Question Can Pinecil Read USB-C Cable E-Marker Chips? Garywoo 1 769 05-13-2024, 01:31 PM
Last Post: tllim
  Connecting a power supply to the Pinecil jon_bondy 1 1,076 02-29-2024, 07:37 PM
Last Post: Okedokey
  Crippling noise from inside pinecil during a few minutes high power soldering. dreieck 2 1,596 01-31-2024, 12:34 AM
Last Post: suga7

Forum Jump:


Users browsing this thread: 2 Guest(s)