Created
February 6, 2019 16:04
-
-
Save Poolitzer/db886b1028b7d7a6654df39f03af55cb to your computer and use it in GitHub Desktop.
This is an example Instantview for the presse-eifel.de website
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~version: "2.0" | |
# this IV is a pretty basic example for a pretty basic website. LET'S GO | |
?exists: //meta[@content="article"] | |
# very easy way to determine if our IV should be generated or not. Works well. | |
body: //article | |
title: $body//h1[1] | |
channel: "@PresseEifel" | |
# basic variables, its their official channel, so we set it as well. | |
author: //a[@rel="author"] | |
author_url: //a[@class="url fn n"]/@href | |
# its only Presse-Eifel so long, but who knows, maybe this is going to change | |
@remove: //p[@class="postmetadata"] | |
@remove: //p[@class="categories"] | |
@remove: //div[@class="writer"] | |
# This removes unnecessary parts of our target website. | |
@before(" "): $body//p/text()[not(ends-with(., ' '))]/next-sibling::br | |
@remove: //br | |
@replace("\u00a0", ""): //p/text() | |
# This is actually a very special case. Our website likes to put random breaks in its paragraphs. So we just replace them with spaces and then remove whitespaces which are also there for a weird reason. Moving on. | |
@remove: $body//img[has-class("crazy_lazy")] | |
@before_el("./../self::figcaption"): //noscript | |
# A great way to get images which aren't loaded directly for the user. Now they are in our IV | |
$cover_path: //meta[@property="og:image"] | |
@set_attr(src, @content) | |
@replace_tag(<img>) | |
cover | |
# Nice little way to set this (on the main site invisible) cover. We take it from the open graph tag, put the content attribute as the src one and then replace the meta tag with the img. After that, we only need to set it as our cover. | |
# AND WE ARE DONE. Thanks for your attention. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment