Skip to content

Instantly share code, notes, and snippets.

@ranman
Created November 13, 2018 04:07
Show Gist options
  • Save ranman/4dcfce14eaaabd558c5d966927569d01 to your computer and use it in GitHub Desktop.
Save ranman/4dcfce14eaaabd558c5d966927569d01 to your computer and use it in GitHub Desktop.
grab aws posts
var stuff = []
Array.from(document.querySelectorAll(".blog-post")).forEach(function (item) {
stuff.push({
"image": item.querySelector('.wp-post-image').src,
"url": item.querySelector('a').href,
"description": item.querySelector('p').innerText,
"title": item.querySelector('h2').innerText,
"date": item.querySelector('time').dateTime
})
})
copy(JSON.stringify(stuff))
import json
with open("data/awsblogs.json") as f:
data = json.loads(f.read())
for item in data:
temp = f"""\
+++
author = "Randall Hunt"
date = {item['date']}
description = "{item['description']}"
draft = false
title = "{item['title']}"
vanity = "{item['url']}"
image = "{item['image']}"
tags = ["aws"]
categories = ["aws"]
+++
"""
fn = item['title'].lower() \
.replace(' ', '-') \
.replace(' ', '') \
.replace('.', '') \
.replace(',', '') \
.replace(')', '') \
.replace('(', '') \
.replace('/', '') \
.replace('–', '') \
.replace('--', '-')\
.replace('!', '') + '.md'
text = temp.format()
with open('content/blog/aws/{}'.format(fn), 'w') as f:
f.write(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment