adding download party notebooks and files

master
manetta 4 years ago
parent 794205b841
commit 6a83f8eed1

@ -0,0 +1,72 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Beautifulsoup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import urllib\n",
"from bs4 import BeautifulSoup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = 'https://go-dh.github.io/mincomp/thoughts/2016/10/02/minimal-definitions/'\n",
"response = urllib.request.urlopen(url)\n",
"html = response.read()\n",
"soup = BeautifulSoup(html, 'html.parser')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(soup.prettify())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

@ -0,0 +1,74 @@
==================================================================================
==================================================================================
==================================================================================
==================================================================================
==================================================================================
==================================================================================
=====================================autonomy=====================================
==================================autonomyequality================================
==================================autonomysocially================================
===============================sociallymutuallysocially===========================
============================sociallymutuallyautonomyunderway======================
============================globallymutuallyAutonomyunderway======================
==========================Autonomymutuallyequalityunderwayautonomy================
=========================sociallyautonomysociallyunderwayequality=================
==================================================================================
==================================================================================
==================================================================================
==================================================================================
==================================================================================
==========================================================================mutually
==================================================================autonomyequality
==================================================================humanityautonomy
==========================================================sociallymutuallysocially
==================================================sociallymutuallysociallyunderway
==================================================autonomymutuallyAutonomyunderway
==========================================Autonomymutuallyequalityunderwayautonomy
==========================================sociallyautonomygloballyunderwayequality
=============================================================//===/========//=/==/
====================================================================//===/====/=//
===========================================================================/===//=
==================================================================================
==========================================================================/=======
==================================================================================
==================================================================================
=============================mutually===============================/=============
==========================autonomyequality====================================/===
==========================sociallyautonomy========================================
=======================sociallymutuallysocially========================/==========
====================sociallymutuallysociallyunderway==============================
====================globallymutuallyAutonomyunderway==============================
==================Autonomymutuallyequalityautonomyautonomy========================
==================sociallyautonomysociallyunderwayequality========================
========================/////=========//===/======================================
=========================///======/===============================================
========================/=/=======//==============================================
======================/=====/=====================================================
========================/=========================================================
==================================================================================
==================================================================================
=======================/============================mutually======================
==============================================autonomyequality====================
===========================/==================sociallysocially====================
===================/======================sociallymutuallysocially================
========================================sociallymutuallysociallyunderway==========
=====================================sociallymutuallyAutonomyunderway=============
====================================Autonomymutuallyequalityunderwayautonomy======
==================================autonomyAutonomyautonomysociallyunderwayequality
==================================underwayAutonomyautonomysociallyunderwayequality
==================================sociallyequalityautonomyunderwayunderwayequality
==========================equalityautonomymutuallysociallysociallyunderwayequality
==========================mutuallyautonomyequalitysociallyunderwaymutuallymutually
==========================Autonomyunderwaymutuallysociallyautonomyunderwaysocially
==================sociallymutuallyunderwayautonomyequalityautonomymutuallyAutonomy
==================sociallymutuallyunderwayautonomyequalityautonomymutuallyAutonomy
==========equalitysociallymutuallyunderwayautonomyAutonomyautonomysociallyequality
==========underwayequalitysociallyautonomyautonomyautonomyunderwayequalitysocially
==========underwayAutonomyhumanityautonomygloballyautonomyhumanityequalitysocially
==========underwayequalityautonomyautonomyautonomyautonomyautonomyequalitysocially
========lygloballyequalitysociallyautonomyautonomyautonomyunderwayequalitysocially
========underwayequalitysociallyautonomyautonomygloballyunderwayequalitysociallyhu
========tyunderwayequalitysociallyautonomyautonomyautonomyunderwayequalitysocially
========underwayequalitysociallyautonomyAutonomyautonomyunderwayequalitysociallyau
autonomyunderwayequalitysociallyautonomygloballyautonomyunderwayequalitysociallyso
ygloballyunderwayequalitysociallyautonomygloballyunderwayunderwayequalitysociallya

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>This is my page generated with Jinja!</title>
</head>
<body>
<h1>Hello {{ name }}!</h1>
</body>
</html>

@ -0,0 +1,254 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Jinja templates"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from jinja2 import Template "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Jinja\n",
"\n",
"https://jinja.palletsprojects.com/en/2.11.x/\n",
"\n",
"> Jinja is a modern and designer-friendly templating language for Python (...). It is fast, widely used and secure with the optional sandboxed template execution environment:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Basic usage of Jinja\n",
"template = Template('Hello {{ name }}!')\n",
"you = 'XPUB1'\n",
"output = template.render(name=you)\n",
"print(output)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Jinja is very useful for generating HTML pages\n",
"# Let's start with a HTML snippet: \n",
"template = Template('<h1>Hello {{ name }}!</h1>')\n",
"you = 'XPUB1'\n",
"html = template.render(name=you)\n",
"print(html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# But these templates can be much longer.\n",
"# Let's now use a separate jinja-template.html file, as our template:\n",
"template_file = open('jinja-template.html').read()\n",
"template = Template(template_file)\n",
"you = 'XPUB1'\n",
"html = template.render(name=you)\n",
"print(html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## For loops & if / else"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### For loops\n",
"\n",
"For loops are written in a *pythonic* way.\n",
"\n",
"What is different, is the \"closing tag\" `{% endfor %}`.\n",
"\n",
"```\n",
"{% for item in list %}\n",
" \n",
" {{ item }}\n",
" \n",
"{% endfor %}\n",
"```\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"template = Template('''\n",
"\n",
"<h1>Hello to</h1>\n",
"\n",
"{% for name in XPUB1 %}\n",
"\n",
" <h2>{{ name }}<h2>\n",
"\n",
"{% endfor %}\n",
"\n",
"''')\n",
"XPUB1 = ['you', 'you', 'you']\n",
"html = template.render(XPUB1=XPUB1)\n",
"print(html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Or display it in HTML here in the notebook directly :)\n",
"from IPython.core.display import HTML\n",
"HTML(html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### if / else\n",
"\n",
"Also if / else statements are written in a *pythonic* way.\n",
"\n",
"The only thing again that is new, is the \"closing tag\" `{% endif %}`.\n",
"\n",
"```\n",
"{% for item in list %}\n",
" \n",
" {% if 'hello' in item %}\n",
"\n",
" <h1>HELLO</h1>\n",
" \n",
" {% else %}\n",
" \n",
" {{ item }}\n",
" \n",
" {% endif %}\n",
" \n",
"{% endfor %}\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"template = Template('''\n",
"\n",
"<h1>Hello to</h1>\n",
"\n",
"{% for name in XPUB1 %}\n",
"\n",
" {% if name == 'me' %}\n",
"\n",
" <h2 style=\"color:magenta;\">{{ name }}<h2>\n",
" \n",
" {% else %}\n",
"\n",
" <h2>{{ name }}<h2>\n",
" \n",
" {% endif %}\n",
"\n",
"{% endfor %}\n",
"\n",
"''')\n",
"XPUB1 = ['you', 'me', 'you']\n",
"html = template.render(XPUB1=XPUB1)\n",
"HTML(html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further diving\n",
"\n",
"More syntax details can be found here: https://jinja.palletsprojects.com/en/2.11.x/templates/"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading…
Cancel
Save