xenial-black•3y ago
But for now the thing I would like the
But for now the thing I would like the most is an endpoint to get data about current customer count and estimated revenue so I don't have to login to apify.com and check it but can send it to my own dashboard automatically
5 Replies
ambitious-aqua•3y ago
You might be able to do it through the developer tools console on the website for now, I wrote some simple code for getting users, runs, and profit where I just collect the data later myself (so I can track changes over time) but you could make it send the data to your server.
setInterval(function(){
var users = document.getElementsByClassName('ActorDetailHeader-insights-value')[1].textContent;
var runs = document.getElementsByClassName('ActorDetailHeader-insights-value')[2].textContent;
var profit = document.getElementsByClassName('text__Text-sc-1b0f4zr-0 bVqMzs PublicActorStatistics-Metric-Values-Absolute')[2].textContent;
console.log(new Date(), 'Users:', users, 'Runs:', runs, 'Profit:', profit); }, 60000);
console.log(new Date(), 'Users:', users, 'Runs:', runs, 'Profit:', profit); }, 60000);
@Jonathan Larson just advanced to level 3! Thanks for your contributions! 🎉
stormy-gold•3y ago
Thanks @Jonathan Larson guess I should setup a scraper on apify to scrape this data then 😅🤣 preferably I would like to use an API but this might work as well
ambitious-aqua•3y ago
Yeah lol. I would just make a scraper but I haven’t worked with cookies much and don’t want to risk getting banned.
ambitious-aqua•3y ago
The html for profit just changed to "sc-bczRLJ fKVRiu textStyledText-sc-1b0f4zr-0 gCemny PublicActorStatistics-Metric-Values-Absolute" (at least for me). I have a dashboard set up and just run a spare laptop with tapermonkey.
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://console.apify.com/actors/wHMoznVs94gOcxcZl/publication
// @icon https://www.google.com/s2/favicons?sz=64&domain=apify.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
var users, runs, profit;
// This will run the code in the function every minute.
setInterval(function() {
users = document.getElementsByClassName('ActorDetailHeader-insights-value')[1].textContent;
runs = document.getElementsByClassName('ActorDetailHeader-insights-value')[2].textContent;
// profit = document.getElementsByClassName('textText-sc-1b0f4zr-0 bVqMzs PublicActorStatistics-Metric-Values-Absolute')[2].textContent;
profit = document.getElementsByClassName('sc-bczRLJ fKVRiu text__StyledText-sc-1b0f4zr-0 gCemny PublicActorStatistics-Metric-Values-Absolute')[2].textContent;
console.log(new Date(), 'Users:', users, 'Runs:', runs, 'Profit:', profit);
var yourData = {
"time": new Date(),
"Users": users,
"Runs": runs,
"Profit": profit
};
fetch({ENDPOINT HERE}, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(yourData),
});
}, 60000); // 60000 milliseconds = 1 minute
// This will refresh the page every 10 minutes.
setInterval(function() {
location.reload();
}, 600000); // 600000 milliseconds = 10 minutes
})();
It needs to be run allowing insecure content.