DEV Community

Discussion on: I'm concerned with the move that FreeCodeCamp just pulled by leaving Medium

 
lkopacz profile image
Lindsey Kopacz

I would check the one Ben put in this blog post.

Thread Thread
 
joshcheek profile image
Josh Cheek

Looks like you might be able to get it via the API: github.com/Medium/medium-api-docs#...

Eg they say a post object has a canonicalUrl, attribute. I can't tell from reading the docs, whether you can GET them via the API. All the examples are creating Medium posts via POST requests, and none are showing existing posts via GET requests.

But you presumably found some way to get it, so if you're getting it through an API endpoint, then check it for the canonicalUrl attribute. And if you're getting it by scraping it, then check for the link tag, eg this prints the expected value:

curl -s https://medium.com/free-code-camp/the-most-important-non-programming-skills-for-programmers-d39fadc1a0fa \
 | ruby -ne '~/<link\s+rel="can.*?"([^"]*)">/ && puts($1)'
Enter fullscreen mode Exit fullscreen mode

(in reality, I'd use the CSS selector link[rel="canonical"], but I wanted an example that didn't require installing fancy tooling)