Skip to content

Instantly share code, notes, and snippets.

@mals14
mals14 / scrapeLinkedinSearch.js
Created January 13, 2024 23:39 — forked from adrianhorning08/scrapeLinkedinSearch.js
Scrape Linkedin Search
async function scrapeLinkedinSearch() {
let allProfiles = [];
let page = 1;
window.scrollTo(0, document.body.scrollHeight);
await new Promise((resolve) => setTimeout(resolve, 500));
// find the button aria-label="Next"
let nextButton = document.querySelector('button[aria-label="Next"]');
const peeps = getProfiles();
allProfiles.push(...peeps);
@mals14
mals14 / index.js
Created January 13, 2024 23:39 — forked from adrianhorning08/index.js
Create CSV on frontend
export function createCSV(data, fileName) {
const headers = Object.keys(data[0]);
const csvContent = [
headers.join(","),
...data.map((row) =>
headers
.map((header) => {
const value = row[header];
if (value === null) return "null";
@mals14
mals14 / zillowScraper.js
Created January 13, 2024 23:38 — forked from adrianhorning08/zillowScraper.js
Zillow Scraper
async function scrollDown() {
const wrapper = document.querySelector("#search-page-list-container");
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 600;
var timer = setInterval(async () => {
var scrollHeightBefore = wrapper.scrollHeight;
wrapper.scrollBy(0, distance);
totalHeight += distance;
@mals14
mals14 / JXA Resources.md
Created October 15, 2021 16:00 — forked from JMichaelTX/JXA Resources.md
JavaScript for Automation (JXA) Resources

JXA Resources

Revised: 2019-11-28 16:16 GMT-6

JXA

This is a list of the key resources I have found useful. If you know of others, please post in a comment below, and I will add to this list.

I have tried to order this list in the order that, to me, is best for learning JXA from scratch. We all learn a bit diferently, so adjust to suit your style/needs. Please post if you have suggestions on learning JXA.

@mals14
mals14 / jxaClickAppSubMenuItem.applescript
Created December 2, 2020 13:42 — forked from bumaociyuan/jxaClickAppSubMenuItem.applescript
Yosemite JXA Javascript Function for clicking application sub-menu items
// Click an OS X app sub-menu item
// 2nd argument is an array of arbitrary length (exact menu item labels, giving full path)
// e.g. menuItemClick("InqScribe", ['View', 'Aspect Ratio', 'Use Media Ratio'])
// Note that the menu path (spelling & sequence) must be exactly as in the app
// See menuItemTestClick() below for a slower version which reports any errors
// For OS X 10.10 Yosemite JXA JavaScript for Automation
@mals14
mals14 / jxaClickAppSubMenuItem.applescript
Created December 2, 2020 13:40 — forked from RobTrew/jxaClickAppSubMenuItem.applescript
Yosemite JXA Javascript Function for clicking application sub-menu items
// Click an OS X app sub-menu item
// 2nd argument is an array of arbitrary length (exact menu item labels, giving full path)
// e.g. menuItemClick("InqScribe", ['View', 'Aspect Ratio', 'Use Media Ratio'])
// Note that the menu path (spelling & sequence) must be exactly as in the app
// See menuItemTestClick() below for a slower version which reports any errors
// For macOS Yosemite to Sierra
@mals14
mals14 / Get value at list or array index or "None" if out of range in Python.md
Last active June 25, 2020 17:50
Get value at list/array index or "None" if out of range in Python

I find list slices good for this:

>>> x = [1, 2, 3]
>>> a = x [1:2]
>>> a
[2]
>>> b = x [4:5]
>>> b
[]
@mals14
mals14 / how to scroll a page with javascript.md
Created June 19, 2020 02:40
how to scroll a page with javascript

How to Scroll a Page With JavaScript

Copied from: How to Scroll the Page With JavaScript Link

This page demonstrates how to use the JavaScript scrollBy and setTimeout methods to make a web page scroll down automatically. Change the timeout value to alter the scrolling speed in milliseconds. The example function below (arbitrarily called pageScroll) shows how this can work:

function pageScroll() {
    	window.scrollBy(0,50); // horizontal and vertical scroll increments
 scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds
@mals14
mals14 / sleep pause capability in javascript.md
Last active June 19, 2020 02:33
sleep pause capability in javascript.md

sourced from: What is the JavaScript version of sleep()? - Stack Overflow Link

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function demo() {
  console.log('Taking a break...');
  await sleep(2000);
 console.log('Two seconds later, showing sleep in a loop...');
@mals14
mals14 / example of how to insert a dictionary into sqlite database.py
Created June 14, 2020 16:15
example of how to insert a dictionary into sqlite database python
# example of how to insert a dictionary into sqlite database
# suorce - https://stackoverflow.com/questions/10913080/python-how-to-insert-a-dictionary-to-a-sqlite-database
def post_row(conn, tablename, rec):
keys = ','.join(rec.keys())
question_marks = ','.join(list('?'*len(rec)))
values = tuple(rec.values())
conn.execute('INSERT INTO '+tablename+' ('+keys+') VALUES ('+question_marks+')', values)