Hack Forums
[Python] Store all the sold items of Shopify! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Store all the sold items of Shopify! (/showthread.php?tid=5476922)



Store all the sold items of Shopify! - DarkDelta - Nov 27, 2016

I made a little script for HackingDoge and he allowed me to share the source with you all.

So, without further ado, here's the script!

PHP Code

<?php 
import websocket
import json


def on_message
(ws, message):
    
j_message = json.loads(message)
    if 
j_message["event"] == "RandomShopProduct":
        
with open("products_bought.txt", "a") as fw:
            
fw.write("New product from " + j_message["hostname"] + "\r\n")
            
fw.write("Product name: " + j_message["shopify_product"]["title"] + "\r\n")
            
fw.write("Url: https://"+j_message["hostname"]+"/products/"+j_message["shopify_product"]["handle"] + "\r\n\r\n")
        print(
"New product from " + j_message["hostname"])
        print(
"Product name: " + j_message["shopify_product"]["title"])
        print(
"Url: https://"+j_message["hostname"]+"/products/"+j_message["shopify_product"]["handle"])
        print(
"-----------------------------------------------------------")


def on_error(ws, error):
    print(
error)


def on_close(ws):
    print(
"### closed ###")


if 
__name__ == "__main__":
    
ws = websocket.WebSocketApp("wss://gopush.herokuapp.com/ws/private-all",
                              
on_message = on_message,
                              
on_error = on_error,
                              
on_close = on_close)
    
ws.run_forever(sslopt={"cert_reqs": websocket.ssl.CERT_NONE}) 

To set it up, run "pip install websocket-client" and then run the script.
It'll store all sold items in a text file in the same folder as the script and display them in the console as well.

Enjoy! 🎉


* - Frukt - Nov 27, 2016

Awesome share, from your posts I can see that you are really experienced when it comes to programming.

Good job!


* - DarkDelta - Nov 27, 2016

(Nov 27, 2016 09:59 AM)FruktFPS Wrote:  Awesome share, from your posts I can see that you are really experienced when it comes to programming.

Good job!

Thanks dude 🎉🤗


* - 4158996621556 - Nov 29, 2016

Looks like the website stopped updating for unknown reasons.

I must say that the script worked fine and got me lots of highly needed information.

DarkDelta is a BEAST!