Skip to content

Instantly share code, notes, and snippets.

@remi
Last active April 14, 2022 05:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save remi/da04f16bd05250a6283dc3b1ca9a1ef3 to your computer and use it in GitHub Desktop.
Save remi/da04f16bd05250a6283dc3b1ca9a1ef3 to your computer and use it in GitHub Desktop.
Extract canonical URL from Apple News URL
#!/bin/bash
# Usage:
#
# 1. Create a `apple-news` file somewhere in your $PATH with the content of this file
# 2. That’s it! You can now use the `apple-news` utility:
#
# ```
# $ apple-news https://apple.news/AKoDCWtVEQP2w7Ld657lgIg
# https://www.theguardian.com/technology/2022/mar/30/dyson-launches-zone-air-purifying-bluetooth-headphones-with-visor
# ```
curl -s -XGET $1 | grep "redirectToUrl(\"" | sed -e "s/^ *redirectToUrl(\"//" | sed -e "s/\");$//"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment