【发布时间】:2018-08-17 09:49:46
【问题描述】:
我将如何扭转 Google 的 AMP api 的流程?
我希望获取一个 AMP(加速移动页面)网址并提供常规(原始)网址。我想知道是否有人知道如何在 Python(或任何其他语言)中做到这一点? 任何帮助将不胜感激。
一个例子:
https://amp.cnn.com/cnn/2018/03/08/politics/jeff-flake-anti-tariff-bill/
预期输出:
https://cnn.com/2018/03/08/politics/jeff-flake-anti-tariff-bill/
第二个例子:
https://www.google.ca/amp/s/mobile.nytimes.com/2018/03/08/us/politics/trump-tariff-announcement.amp.html
预期输出:
https://www.nytimes.com/2018/03/08/us/politics/trump-tariff-announcement.html
第三个(也是最后一个)示例:
https://www.google.ca/amp/s/www.theverge.com/platform/amp/2018/3/8/17097904/android-ios-smartphone-brand-loyalty
预期输出:
https://www.theverge.com/2018/3/8/17097904/android-ios-smartphone-brand-loyalty
不幸的是,AMP 的实现似乎有很大差异。我想一种方法可能是去掉任何“amp”和周围的点 (.) 或斜线 (/),但是,我可以想象这样一种情况,这不是最明智的方法(主要是如果页面 URL 实际上应该在其结尾等中有amp(它出现在常规浏览中)。
【问题讨论】:
-
您能否再澄清一下 - 不确定您的意思。也许添加一个具体的例子,比如 url/link 作为输入和你期望的输出
-
@daKmoR 添加了 3 个示例
标签: python python-3.x url amp-html