Created
November 13, 2018 04:07
-
-
Save ranman/4dcfce14eaaabd558c5d966927569d01 to your computer and use it in GitHub Desktop.
grab aws posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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