Skip to content

Instantly share code, notes, and snippets.

@plantvsbirds
Last active January 5, 2023 09:17
Show Gist options
  • Save plantvsbirds/526c4bf5a50c74e97c412e422196defa to your computer and use it in GitHub Desktop.
Save plantvsbirds/526c4bf5a50c74e97c412e422196defa to your computer and use it in GitHub Desktop.
download your copy of epub/mobi of caltech fenman lecture on physics vol i http://www.feynmanlectures.caltech.edu/I_toc.html, powered by https://github.com/lepture/getbook/
{
"uid": "feynman-lecture-vol-i",
"title": "The Feynman Lectures on Physics, Volume I",
"author": "Richard Feynman",
"chapters": ["http://www.feynmanlectures.caltech.edu/I_89.html","http://www.feynmanlectures.caltech.edu/I_90.html","http://www.feynmanlectures.caltech.edu/I_91.html","http://www.feynmanlectures.caltech.edu/I_92.html","http://www.feynmanlectures.caltech.edu/I_01.html","http://www.feynmanlectures.caltech.edu/I_02.html","http://www.feynmanlectures.caltech.edu/I_03.html","http://www.feynmanlectures.caltech.edu/I_04.html","http://www.feynmanlectures.caltech.edu/I_05.html","http://www.feynmanlectures.caltech.edu/I_06.html","http://www.feynmanlectures.caltech.edu/I_07.html","http://www.feynmanlectures.caltech.edu/I_08.html","http://www.feynmanlectures.caltech.edu/I_09.html","http://www.feynmanlectures.caltech.edu/I_10.html","http://www.feynmanlectures.caltech.edu/I_11.html","http://www.feynmanlectures.caltech.edu/I_12.html","http://www.feynmanlectures.caltech.edu/I_13.html","http://www.feynmanlectures.caltech.edu/I_14.html","http://www.feynmanlectures.caltech.edu/I_15.html","http://www.feynmanlectures.caltech.edu/I_16.html","http://www.feynmanlectures.caltech.edu/I_17.html","http://www.feynmanlectures.caltech.edu/I_18.html","http://www.feynmanlectures.caltech.edu/I_19.html","http://www.feynmanlectures.caltech.edu/I_20.html","http://www.feynmanlectures.caltech.edu/I_21.html","http://www.feynmanlectures.caltech.edu/I_22.html","http://www.feynmanlectures.caltech.edu/I_23.html","http://www.feynmanlectures.caltech.edu/I_24.html","http://www.feynmanlectures.caltech.edu/I_25.html","http://www.feynmanlectures.caltech.edu/I_26.html","http://www.feynmanlectures.caltech.edu/I_27.html","http://www.feynmanlectures.caltech.edu/I_28.html","http://www.feynmanlectures.caltech.edu/I_29.html","http://www.feynmanlectures.caltech.edu/I_30.html","http://www.feynmanlectures.caltech.edu/I_31.html","http://www.feynmanlectures.caltech.edu/I_32.html","http://www.feynmanlectures.caltech.edu/I_33.html","http://www.feynmanlectures.caltech.edu/I_34.html","http://www.feynmanlectures.caltech.edu/I_35.html","http://www.feynmanlectures.caltech.edu/I_36.html","http://www.feynmanlectures.caltech.edu/I_37.html","http://www.feynmanlectures.caltech.edu/I_38.html","http://www.feynmanlectures.caltech.edu/I_39.html","http://www.feynmanlectures.caltech.edu/I_40.html","http://www.feynmanlectures.caltech.edu/I_41.html","http://www.feynmanlectures.caltech.edu/I_42.html","http://www.feynmanlectures.caltech.edu/I_43.html","http://www.feynmanlectures.caltech.edu/I_44.html","http://www.feynmanlectures.caltech.edu/I_45.html","http://www.feynmanlectures.caltech.edu/I_46.html","http://www.feynmanlectures.caltech.edu/I_47.html","http://www.feynmanlectures.caltech.edu/I_48.html","http://www.feynmanlectures.caltech.edu/I_49.html","http://www.feynmanlectures.caltech.edu/I_50.html","http://www.feynmanlectures.caltech.edu/I_51.html","http://www.feynmanlectures.caltech.edu/I_52.html"]
}
Goto = (vol,chap,sec) => {
var volstrings =["I","II","III"];
var dest;
var chapstr = "0"+String(chap);
chapstr = chapstr.substr(chapstr.length-2);
dest = volstrings[vol-1] + "_" + chapstr + ".html"
if(typeof(sec)!=='undefined') {
dest += "#Ch" + String(chap) + "-S" + String(sec);
}
return (dest);
}
$('a.chapterlink').toArray().map(a => 'http://www.feynmanlectures.caltech.edu' + eval(a.href.split(':')[1]))
@lzwjava
Copy link

lzwjava commented Sep 13, 2019

Awesome work! Thanks!

@hojnrq
Copy link

hojnrq commented Oct 21, 2019

This doesn't seem to work. It gives

python3.5 /usr/local/bin/getbook -f ./feynman-lecture-vol-i.json
Error: SelectorSyntaxError("The combinator '>' at postion 0, must have a selector before it\n  line 1:\n> p\n^",)
Error: SelectorSyntaxError("The combinator '>' at postion 0, must have a selector before it\n  line 1:\n> p\n^",)
[...]
Error: SelectorSyntaxError("The combinator '>' at postion 0, must have a selector before it\n  line 1:\n> p\n^",)
Error: SelectorSyntaxError("The combinator '>' at postion 0, must have a selector before it\n  line 1:\n> p\n^",)
EPUB: /home/johnrq/dev/flp/feynman-lecture-vol-i.epub

But the epub is empty.

This is on Ubuntu 16.04 with python 3.5.2 and getbook (and dependencies) installed today via pip3:

$ pip3 install getbook
Collecting getbook
  Downloading https://files.pythonhosted.org/packages/7a/a7/4a532e2d49941fed08ac9a225a4ceed25fefe2e3cdca7d38518afbcb4598/getbook-0.3.tar.gz (41kB)
    100% |||||||||||||||||||||||||||||||||| 51kB 2.8MB/s 
Collecting Jinja2 (from getbook)
  Downloading https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl (125kB)
    100% |||||||||||||||||||||||||||||||||| 133kB 5.2MB/s 
Collecting Pillow (from getbook)
  Downloading https://files.pythonhosted.org/packages/dc/bd/ba64273d3fdeb68c74b040e3e42f5a3c2f643e8e65b0b1ad0b18425ed67a/Pillow-6.2.1-cp35-cp35m-manylinux1_x86_64.whl (2.1MB)
    100% |||||||||||||||||||||||||||||||||| 2.1MB 628kB/s 
Collecting beautifulsoup4 (from getbook)
  Downloading https://files.pythonhosted.org/packages/3b/c8/a55eb6ea11cd7e5ac4bacdf92bac4693b90d3ba79268be16527555e186f0/beautifulsoup4-4.8.1-py3-none-any.whl (101kB)
    100% |||||||||||||||||||||||||||||||||| 102kB 8.5MB/s 
Collecting html5lib (from getbook)
  Downloading https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl (117kB)
    100% |||||||||||||||||||||||||||||||||| 122kB 6.8MB/s 
Collecting lxml (from getbook)
  Downloading https://files.pythonhosted.org/packages/85/01/544faf6443e0a81cde4858f8941194825fab9e5de3c73f54879c3c0dc181/lxml-4.4.1-cp35-cp35m-manylinux1_x86_64.whl (5.7MB)
    100% |||||||||||||||||||||||||||||||||| 5.7MB 251kB/s 
Collecting python-dateutil (from getbook)
  Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
    100% |||||||||||||||||||||||||||||||||| 235kB 5.8MB/s 
Collecting requests (from getbook)
  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
    100% |||||||||||||||||||||||||||||||||| 61kB 10.6MB/s 
Collecting MarkupSafe>=0.23 (from Jinja2->getbook)
  Downloading https://files.pythonhosted.org/packages/6e/57/d40124076756c19ff2269678de7ae25a14ebbb3f6314eb5ce9477f191350/MarkupSafe-1.1.1-cp35-cp35m-manylinux1_x86_64.whl
Collecting soupsieve>=1.2 (from beautifulsoup4->getbook)
  Downloading https://files.pythonhosted.org/packages/5d/42/d821581cf568e9b7dfc5b415aa61952b0f5e3dede4f3cbd650e3a1082992/soupsieve-1.9.4-py2.py3-none-any.whl
Collecting webencodings (from html5lib->getbook)
  Downloading https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Collecting six>=1.9 (from html5lib->getbook)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->getbook)
  Downloading https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl (154kB)
    100% |||||||||||||||||||||||||||||||||| 163kB 7.6MB/s 
Collecting idna<2.9,>=2.5 (from requests->getbook)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
    100% |||||||||||||||||||||||||||||||||| 61kB 10.4MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests->getbook)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |||||||||||||||||||||||||||||||||| 143kB 8.3MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->getbook)
  Downloading https://files.pythonhosted.org/packages/e0/da/55f51ea951e1b7c63a579c09dd7db825bb730ec1fe9c0180fc77bfb31448/urllib3-1.25.6-py2.py3-none-any.whl (125kB)
    100% |||||||||||||||||||||||||||||||||| 133kB 8.1MB/s 
Building wheels for collected packages: getbook
  Running setup.py bdist_wheel for getbook ... done
  Stored in directory: /home/johnrq/.cache/pip/wheels/95/ae/57/fabd92310ec4e9f579a269efdf8bc203d6266316575d6162ad
Successfully built getbook
Installing collected packages: MarkupSafe, Jinja2, Pillow, soupsieve, beautifulsoup4, webencodings, six, html5lib, lxml, python-dateutil, certifi, idna, chardet, urllib3, requests, getbook
Successfully installed Jinja2-2.8 MarkupSafe-0.23 Pillow-3.1.2 beautifulsoup4-4.4.1 certifi-2017.4.17 chardet-3.0.4 getbook html5lib-0.999 idna-2.5 lxml-3.5.0 python-dateutil requests-2.18.1 six-1.11.0 soupsieve urllib3-1.21.1 webencodings

@plantvsbirds
Copy link
Author

plantvsbirds commented Oct 22, 2019 via email

@hojnrq
Copy link

hojnrq commented Oct 22, 2019

likely upstream (getbook) issue

I doubt it, given the getbook code hasn't changed in more than one year (yet someone above reported it works, apparently).

Could you try it yourself right now to see if it works? If it does work, can you please report the exact versions of your python and following packages:

Jinja2
MarkupSafe
Pillow
beautifulsoup4
certifi
chardet
getbook
html5lib
idna
lxml
python-dateutil
requests
six
soupsieve
urllib3
webencodings

@emaland
Copy link

emaland commented Jun 30, 2021

For anyone who comes across this thread (as I just did), to fix this just:

pip install beautifulsoup4==4.6.0

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