Skip to content

Instantly share code, notes, and snippets.

@bmweiner
Created July 9, 2019 01:46
Show Gist options
  • Save bmweiner/e1df98d4ae77296687d09621c0b0ac73 to your computer and use it in GitHub Desktop.
Save bmweiner/e1df98d4ae77296687d09621c0b0ac73 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# downloads and converts yamaha ebook to pdf\n",
"# https://www.yamahapubs.com/ebook/LIT-11616-29-22/LIT-11616-29-22.html#p=1"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import io\n",
"from urllib.request import urlopen\n",
"import ssl\n",
"from PIL import Image"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"start_page = 1\n",
"end_page = 488\n",
"pub = 'LIT-11616-29-22'\n",
"\n",
"url = 'https://www.yamahapubs.com/ebook/{}'.format(pub) + '/files/mobile/{}.jpg'\n",
"fileout = '{}_p{}-{}.pdf'.format(pub, start_page, end_page)\n",
"\n",
"context = ssl._create_unverified_context()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"images = []\n",
"for n in range(start_page, end_page + 1):\n",
" with urlopen(url.format(n), context=context) as f:\n",
" images.append(Image.open(io.BytesIO(f.read())))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"images[0].save(fileout, \"PDF\", resolution=100.0, save_all=True, append_images=images[1:])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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": 2
}
@bmweiner
Copy link
Author

bmweiner commented Jul 9, 2019

Yamaha MT-07 Service Manual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment