Update regex

This commit is contained in:
Andros Fenollosa 2021-07-31 15:32:56 +02:00
parent 1002a57856
commit 285c140fcb
4 changed files with 3 additions and 2 deletions

Binary file not shown.

View File

@ -2,6 +2,7 @@
:root {
--color-black: black;
--color-gray: gray;
--color-background: #f9f7f1;
--height-img: 10rem;
}
@ -16,7 +17,7 @@ body {
padding: 0;
font-family: Newsreader, serif;
color: var(--color-black);
background-image: url("../img/background.jpg");
background-color: var(--color-background);
background-size: 100%;
}
img {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 KiB

View File

@ -43,7 +43,7 @@
(let [url-article (get-in article [:feed :link])
html (:body (client/get url-article {:insecure? true}))
url-og-image (second (re-find #"<meta[^>].*?property=\"og:image(?::url)?\".*?content=\"(.*?)\".*?>|<meta[^>].*?content=\"(.*?)\".*?property=\"og:image(?::url)?\".*?>" html))
url-first-image (second (re-find #"(<main|id=\".*main.*\"|class=\".*main.*\").*<img[^>]+src=\"([^\">]+)\"" html))
url-first-image (second (re-find #"<main.*>[\s\S]*<img[^>]+src=\"([^\"\'|>]+)\"|id=[\'\"] ?main ?[\'\"]>[\s\S]*<img[^>]+src=\"([^\"\'|>]+)\"|class=[\'\"] ?main ?[\'\"]>[\s\S]*<img[^>]+src=\"([^\"\'|>]+)\"" html))
images [url-og-image url-first-image]
url-final-image (first (filter (fn [item] (not (nil? item))) images))]
(assoc article :cover url-final-image))) articles))