-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopulate_app_dev.py
29 lines (28 loc) · 1.09 KB
/
populate_app_dev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
from bs4 import BeautifulSoup, element
path = os.path.abspath("./portfolio/newportfolio.html")
template = open(path, "r")
soup = BeautifulSoup(template, "html.parser")
listofApps = soup.find("ul", class_="portfolio_ul")
for app in listofApps.children:
print(type(app))
if isinstance(app, element.NavigableString):
continue
paragraphs = app.find_all("p")
title = app.find("h3").string
fileTitle = title.replace(" ", "").replace("/","")
url = paragraphs[0].find("a")['href']
audience = paragraphs[1].contents[1].lstrip(' ')
description = paragraphs[2].contents[1].lstrip(' ')
output = open("./app_dev/_posts/2018-02-13-"+fileTitle+".md", "w")
output.write("---\n")
output.write("layout: article\n")
output.write("title: \""+title+"\"\n")
output.write("description: \""+description+"\"\n")
output.write("current-url: "+url+"\n")
output.write("audience: \""+audience+"\"\n")
output.write("Launched: Jan 2018\n")
output.write("tags: \n")
output.write(" - Static Site - Jekyll\n\n")
output.write("---\n")
output.close()