From 842f528d7317bd6e20eda9cfdc4de2b8b2fe13bb Mon Sep 17 00:00:00 2001 From: faucet <102884856+faucetlol@users.noreply.github.com> Date: Tue, 19 Dec 2023 18:12:44 +0000 Subject: [PATCH] Use original images with Commishes scraper (#109) * Use original images with Commishes scraper * %r for regex --- app/logical/scraper/commishes.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/logical/scraper/commishes.rb b/app/logical/scraper/commishes.rb index 5e9c17ae..31691431 100755 --- a/app/logical/scraper/commishes.rb +++ b/app/logical/scraper/commishes.rb @@ -48,12 +48,14 @@ def get_ids_from_page(page) def get_details(urls) urls.map do |url| html = fetch_html(url, headers: headers) + script_containing_id = html.xpath("//script[contains(text(), '/upload/tag/')]").first + original_image_id = script_containing_id.text.match(%r{/(\d+)/remove/})[1] { identifier: url.split("/").pop, title: html.at("h1#upload-title").content, description: "", created_at: html.at("h1#upload-title").parent.content.sub(/.*\u00a9.*(\d{4}) -/, '\1'), - file_url: html.at("img#preview")["data-large"], + file_url: "https://portfolio.commishes.com/image/#{original_image_id}/original/", } end end