I use pandoc to turn html into epub. Something like the following script could be used.
#!/bin/sh
curl -- $@ | pandoc --standalone --smart -T '' -o - -f html -t epub
#!/bin/sh
curl -- $@ | pandoc --standalone --smart -T '' -o - -f html -t epub
Pandoc parses the html, converts the parts it can to its internal document model and converts this into EPUB. It doesn't do any intentional stripping, but some things get thrown out because it is not part of its document model.
Pandoc is not a single purpose application, but rather the document format swiss-army knife. [0]