Skip to content

Commit

Permalink
Delete unused screenshots and update README.md and parse-readme.js
Browse files Browse the repository at this point in the history
  • Loading branch information
maxontech committed Mar 14, 2024
1 parent 5a0f061 commit 198638b
Show file tree
Hide file tree
Showing 22 changed files with 209 additions and 118 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
| [Facebook](https://www.facebook.com) | #socialmedia; #networking |
| [Amazon](https://www.amazon.com) | #ecommerce; #retail |
| [Netflix](https://www.netflix.com) | #streaming; #entertainment |
| [Spotify](https://www.spotify.com) | #music; #streaming |
| [Microsoft](https://www.microsoft.com) | #technology; #software |
132 changes: 126 additions & 6 deletions docs/data.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,130 @@
[
{
"timestamp": "2024-03-09T22:57:11.586Z",
"firstName": "Ad42sw2am",
"lastName": "Alst4ws2on",
"githubProfile": "https://vuejs.org/",
"githubReadme": "https://vuejs.org/",
"screenshotPath": "screenshots/6s.jpeg"
"timestamp": "2024-03-14T20:17:31.711Z",
"title": "Accelerate the Development of AI Applications | Scale AI",
"url": "https://www.scale.ai",
"companyName": "Scale",
"screenshotPath": "screenshots/Scale.jpeg",
"tags": [
"startup"
],
"stack": "React",
"timeToPageLoad": 439
},
{
"timestamp": "2024-03-14T20:17:33.325Z",
"title": "The #1 AI Headshot Generator for Professional Headshots",
"url": "https://www.headshotpro.com",
"companyName": "Head Shot Pro",
"screenshotPath": "screenshots/HeadShotPro.jpeg",
"tags": [
"startup"
],
"stack": "Nuxt.js",
"timeToPageLoad": 41
},
{
"timestamp": "2024-03-14T20:17:34.118Z",
"title": "Airbnb | Vacation rentals, cabins, beach houses, & more",
"url": "https://www.airbnb.com",
"companyName": "Airbnb",
"screenshotPath": "screenshots/Airbnb.jpeg",
"tags": [
"travel",
"rental"
],
"stack": "React",
"timeToPageLoad": 462
},
{
"timestamp": "2024-03-14T20:17:34.987Z",
"title": "Erziele Umsätze als Fahrer*in oder bestelle jetzt eine Fahrt | Uber Deutschland",
"url": "https://www.uber.com",
"companyName": "Uber",
"screenshotPath": "screenshots/Uber.jpeg",
"tags": [
"transportation",
"ridesharing"
],
"stack": "",
"timeToPageLoad": 180
},
{
"timestamp": "2024-03-14T20:17:35.580Z",
"title": "Google",
"url": "https://www.google.com",
"companyName": "Google",
"screenshotPath": "screenshots/Google.jpeg",
"tags": [
"search",
"technology"
],
"stack": "",
"timeToPageLoad": 180
},
{
"timestamp": "2024-03-14T20:17:36.056Z",
"title": "Facebook - log in or sign up",
"url": "https://www.facebook.com",
"companyName": "Facebook",
"screenshotPath": "screenshots/Facebook.jpeg",
"tags": [
"socialmedia",
"networking"
],
"stack": "",
"timeToPageLoad": 144
},
{
"timestamp": "2024-03-14T20:17:37.278Z",
"title": "Amazon.com. Spend less. Smile more.",
"url": "https://www.amazon.com",
"companyName": "Amazon",
"screenshotPath": "screenshots/Amazon.jpeg",
"tags": [
"ecommerce",
"retail"
],
"stack": "",
"timeToPageLoad": 510
},
{
"timestamp": "2024-03-14T20:17:38.943Z",
"title": "Netflix - Watch TV Shows Online, Watch Movies Online",
"url": "https://www.netflix.com",
"companyName": "Netflix",
"screenshotPath": "screenshots/Netflix.jpeg",
"tags": [
"streaming",
"entertainment"
],
"stack": "React",
"timeToPageLoad": 595
},
{
"timestamp": "2024-03-14T20:17:40.770Z",
"title": "Spotify - Web Player: Music for everyone",
"url": "https://www.spotify.com",
"companyName": "Spotify",
"screenshotPath": "screenshots/Spotify.jpeg",
"tags": [
"music",
"streaming"
],
"stack": "React",
"timeToPageLoad": 70
},
{
"timestamp": "2024-03-14T20:17:43.056Z",
"title": "Microsoft – Cloud, Computer, Apps und Gaming",
"url": "https://www.microsoft.com",
"companyName": "Microsoft",
"screenshotPath": "screenshots/Microsoft.jpeg",
"tags": [
"technology",
"software"
],
"stack": "jQuery",
"timeToPageLoad": 1060
}
]
45 changes: 33 additions & 12 deletions docs/parse-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,35 @@ const getWebsiteStack = async (page) => {

if (!!window.Nuxt || !!window.__NUXT__)
return 'Nuxt.js';

return '';
});
}

const updateDataFile = async (dataObjects) => {
const dataFilePath = path.join(__dirname, 'data.json');
let existingData;

try {
existingData = JSON.parse(await fs.readFile(dataFilePath, 'utf8'));
} catch (error) {
existingData = [];
}

const newData = dataObjects.filter(dataObject =>
!existingData.some(existingObject => existingObject.companyName === dataObject.companyName)
);

await fs.writeFile(dataFilePath, JSON.stringify([...existingData, ...newData], null, 2));
}

const processFile = async (filePath) => {

data = await fs.readFile(filePath, 'utf8');
const browser = await puppeteer.launch();
const tableRowRegex = /\|\s*\[([^\]]+)\]\(([^)]+)\)\s*\|\s*([^|]+)\s*\|/g;
let dataObjects = [];
let match;

while ((match = tableRowRegex.exec(data)) !== null) {

Expand All @@ -108,19 +127,21 @@ const processFile = async (filePath) => {

const dataObject = {
timestamp: new Date().toISOString(),
title,
url,
companyName,
title: title,
url: url,
companyName: companyName,
screenshotPath: `screenshots/${companyName.replace(/\s/g, '')}.jpeg`,
tags,
tags: tags,
stack: websiteStack,
timeToPageLoad
timeToPageLoad: Math.round(timeToPageLoad),
};
console.log(dataObject);
dataObjects.push(dataObject);
}
await browser.close();

await updateDataFile(dataObjects);

//const json = JSON.stringify(dataObjects, null, 2);
//console.log(json);
}
Expand All @@ -137,16 +158,16 @@ fs.readFile(dataFilePath, 'utf8', (err, data) => {
return;
}
// Initialize an array to hold the existing users
let existingUsers = [];
// Initialize an array to hold the existing data objects
let existingDataObjects = [];
// If the file has data, parse it as JSON and assign it to existingUsers
// If the file has data, parse the data into an array
if (data) {
existingUsers = JSON.parse(data);
existingDataObjects = JSON.parse(data);
}
// Filter out the users that already exist in the data file
const newUsers = users.filter(user => !existingUsers.some(existingUser => existingUser.githubProfile === user.githubProfile));
const newDataObjects = users.filter(user => !existingUsers.some(existingUser => existingUser.githubProfile === user.githubProfile));
// Combine the existing users and the new users
const allUsers = [...existingUsers, ...newUsers];
Expand All @@ -165,5 +186,5 @@ fs.readFile(dataFilePath, 'utf8', (err, data) => {
// Log a success message
console.log('Data written to file');
});
}); */
//});
});
*/
48 changes: 48 additions & 0 deletions docs/screenshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const puppeteer = require('puppeteer');
const fs = require('fs');
const path = require('path');

(async () => {
const data = JSON.parse(fs.readFileSync('docs/data.json', 'utf-8'));
const browser = await puppeteer.launch();

for (const dataObject of data) {
const screenshotPath = path.join('docs', dataObject.screenshotPath);
if (fs.existsSync(screenshotPath)) {
console.log(`Screenshot already exists for ${dataObject.companyName}, skipping.`);
continue;
}

console.log(`Taking screenshot for ${dataObject.companyName} ...`);

const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 720 });
await page.goto(dataObject.url);
await new Promise(resolve => setTimeout(resolve, 3000));

// Scroll to the bottom of the page
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 100;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;

if (totalHeight >= scrollHeight){
clearInterval(timer);
resolve();
}
}, 100);
});
});



await page.screenshot({ path: screenshotPath, fullPage: true });
await page.close();
}

await browser.close();
})();
Binary file removed docs/screenshots/2.jpeg
Binary file not shown.
Binary file removed docs/screenshots/3.jpeg
Binary file not shown.
Binary file removed docs/screenshots/4.jpeg
Binary file not shown.
Binary file removed docs/screenshots/5.jpeg
Binary file not shown.
Binary file removed docs/screenshots/6.jpeg
Binary file not shown.
Binary file removed docs/screenshots/6s.jpeg
Binary file not shown.
Binary file added docs/screenshots/Airbnb.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Amazon.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Facebook.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Google.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/HeadShotPro.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Microsoft.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Netflix.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Scale.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Spotify.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/Uber.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/screenshots/maxontech.jpeg
Binary file not shown.
100 changes: 0 additions & 100 deletions docs/spider.js

This file was deleted.

0 comments on commit 198638b

Please sign in to comment.