Skip to content

Commit

Permalink
Update README with new requirements and history
Browse files Browse the repository at this point in the history
  • Loading branch information
jxu committed Aug 18, 2021
1 parent ebf1a5c commit 66f540e
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ Please report any inaccuracies or give feedback. Thanks.

Inspired by [Kyle Keen's original Local Euler](http://kmkeen.com/local-euler/2008-07-16-07-33-00.html).

Installation and Usage
----------------------

Note: previously PhantomJS was used to download each problem individually as a PDF, and PyPDF2 was used to combine together all problems.
Requirements
------------

Now, use "Print to File" https://projecteuler.net/show=all using Firefox (with no Headers and Footers in options). This is simpler, produces a smaller PDF, and does not rely on the discontinued PhantomJS. The python script to download extra files remains the same functionally.
- Shell tools like curl, zip
- chromium-browser
- [pup](https://github.com/ericchiang/pup)
- pdftk
- ImageMagick
- GhostScript

Requirements:
- Python 3 and BeautifulSoup, lxml, Pillow (`pip install beautifulsoup4 lxml pillow`)
- BeautifulSoup and Pillow are only required for downloading extra text and images (animated GIF only).

My usage process:
Example Usage
-------------

mkdir render
# Save render/problems.pdf with Firefox as above
python3 download_extra.py
cd render
zip problems.zip problems.pdf *.txt *.gif
../download.sh 1 761


History
-------

This simple download-and-combine script has been written several times as exercises in different tools and in response to Project Euler layout changes.

1. The first version used PhantomJS as a headless browser to render the problems, then a separate python script using BeautifulSoup4 to search and download extra files (text and GIF), Pillow to check for animated GIFs, and PyPDF2 to combine the PDFs of all problems into one PDF.
2. Later I discovered Project Euler had a convenient special URL to show all problems on one page (https://projecteuler.net/show=all). This let me simply use Firefox to print a smaller PDF (in pages and size) that did not rely on the discontinued PhantomJS. The python script to download extra files remained the same.
3. Sometime after summer 2020 the convenient URL functionality disappeared, so I had to go back to downloading problems individually and combining them. This time I decided to forgo python and use only shell tools as an exercise (and to produce a smaller script). Chromium in headless mode had a convenient option to print to PDF, pup handled searching the HTML for extra files, pdftk combined the PDFs, and ImageMagick identified animated GIFs. Running the final PDF through GhostScript was able to halve the PDF size.

0 comments on commit 66f540e

Please sign in to comment.