{"id":2621,"date":"2026-07-07T01:48:51","date_gmt":"2026-07-07T01:48:51","guid":{"rendered":"https:\/\/www.cupcakerecipe.net\/?p=2621"},"modified":"2026-07-07T01:48:51","modified_gmt":"2026-07-07T01:48:51","slug":"by-mary","status":"publish","type":"post","link":"https:\/\/www.cupcakerecipe.net\/?p=2621","title":{"rendered":"By: Mary"},"content":{"rendered":"<p>Are these sweet or tart cherries???  It\u2019s almost tart cherry picking time in Door County (in Wisconsin).<\/p>\n<p> version ai :<br \/>\npython<br \/>\nimport requests<br \/>\nfrom bs4 import BeautifulSoup<br \/>\nfrom urllib.parse import urljoin, urlparse<\/p>\n<p>def get_full_content_html(article_url: str) -> str:<br \/>\n    &#8220;&#8221;&#8221;<br \/>\n    Fetches the HTML content from the given URL, extracts the main article content,<br \/>\n    makes relative image and link URLs absolute, and returns the modified HTML.<br \/>\n    Returns an empty string if the article content cannot be found or if the request fails.<br \/>\n    &#8220;&#8221;&#8221;<br \/>\n    try:<br \/>\n        response = requests.get(article_url, timeout=15)<br \/>\n        response.raise_for_status()  # Raise an exception for HTTP errors (like 404, 500)<br \/>\n    except requests.exceptions.RequestException:<br \/>\n        # If the request fails (e.g., network error, DNS, or HTTP error like 404 due to raise_for_status)<br \/>\n        return &#8220;&#8221; # Return empty string as no article content could be retrieved.<\/p>\n<p>    soup = BeautifulSoup(response.text, &#8216;html.parser&#8217;)<\/p>\n<p>    # Construct the base URL for resolving relative paths.<br \/>\n    # urljoin(article_url, &#8216;\/&#8217;) ensures we get the scheme, netloc, and a trailing slash for proper base URL.<br \/>\n    base_url = urljoin(article_url, &#8216;\/&#8217;) <\/p>\n<p>    main_article_element = None<\/p>\n<p>    # Attempt to find the main article content.<br \/>\n    # On Smitten Kitchen, recipe posts are typically within <\/p>\n<article> tags with specific classes.<br \/>\n    # We prioritize finding a &#8216;recipe-post&#8217; article.<br \/>\n    recipe_article = soup.find(&#8216;article&#8217;, class_=&#8217;recipe-post&#8217;)<br \/>\n    if recipe_article:<br \/>\n        main_article_element = recipe_article<br \/>\n    else:<br \/>\n        # Fallback to finding any article with an ID starting with &#8216;post-&#8216;, but explicitly check its title.<br \/>\n        # This helps distinguish a true article from a 404 page that might also use <\/p>\n<article> tags.<br \/>\n        generic_article = soup.find(&#8216;article&#8217;, id=lambda x: x and x.startswith(&#8216;post-&#8216;))<br \/>\n        if generic_article:<br \/>\n            title_element = generic_article.find(&#8216;h1&#8242;, class_=&#8217;entry-title&#8217;)<br \/>\n            # Only consider it a valid article if its title is not &#8220;Page Not Found&#8221;<br \/>\n            if title_element and title_element.get_text(strip=True).lower() != &#8216;page not found&#8217;:<br \/>\n                main_article_element = generic_article<\/p>\n<p>    article_content = None<br \/>\n    if main_article_element:<br \/>\n        # Once a valid article element is identified, find its specific content div.<br \/>\n        article_content = main_article_element.find(&#8216;div&#8217;, class_=&#8217;entry-content&#8217;)<\/p>\n<p>    if not article_content:<br \/>\n        # If no valid article content is found (e.g., it&#8217;s a 404 page, or unexpected structure),<br \/>\n        # return an empty string as per the implied request for &#8220;final article&#8221;.<br \/>\n        return &#8220;&#8221;<\/p>\n<p>    # Process images within the article content<br \/>\n    for img in article_content.find_all(&#8216;img&#8217;):<br \/>\n        # Prioritize &#8216;data-lazy-src&#8217; for the &#8216;src&#8217; attribute, common for lazy-loaded images<br \/>\n        if img.has_attr(&#8216;data-lazy-src&#8217;):<br \/>\n            real_src = img[&#8216;data-lazy-src&#8217;]<br \/>\n            if not urlparse(real_src).netloc:<br \/>\n                img[&#8216;src&#8217;] = urljoin(base_url, real_src)<br \/>\n            else:<br \/>\n                img[&#8216;src&#8217;] = real_src<br \/>\n            del img[&#8216;data-lazy-src&#8217;] # Remove the lazy-load attribute after copying<br \/>\n        elif img.has_attr(&#8216;src&#8217;):<br \/>\n            img_src = img[&#8216;src&#8217;]<br \/>\n            # Convert relative &#8216;src&#8217; URLs to absolute<br \/>\n            if not urlparse(img_src).netloc:<br \/>\n                img[&#8216;src&#8217;] = urljoin(base_url, img_src)<\/p>\n<p>        # Prioritize &#8216;data-lazy-srcset&#8217; for the &#8216;srcset&#8217; attribute<br \/>\n        srcset_str = None<br \/>\n        if img.has_attr(&#8216;data-lazy-srcset&#8217;):<br \/>\n            srcset_str = img[&#8216;data-lazy-srcset&#8217;]<br \/>\n            del img[&#8216;data-lazy-srcset&#8217;] # Remove the lazy-load attribute after copying<br \/>\n        elif img.has_attr(&#8216;srcset&#8217;):<br \/>\n            srcset_str = img[&#8216;srcset&#8217;]<\/p>\n<p>        if srcset_str:<br \/>\n            srcset_values = srcset_str.split(&#8216;,&#8217;)<br \/>\n            new_srcset_values = []<br \/>\n            for val in srcset_values:<br \/>\n                parts = val.strip().split(&#8216; &#8216;)<br \/>\n                if len(parts) > 0:<br \/>\n                    src_url = parts[0]<br \/>\n                    # Convert relative &#8216;srcset&#8217; URLs to absolute<br \/>\n                    if not urlparse(src_url).netloc:<br \/>\n                        absolute_src_url = urljoin(base_url, src_url)<br \/>\n                        parts[0] = absolute_src_url<br \/>\n                    new_srcset_values.append(&#8216; &#8216;.join(parts))<br \/>\n            img[&#8216;srcset&#8217;] = &#8216;, &#8216;.join(new_srcset_values)<\/p>\n<p>        # Remove lazyload-related classes to ensure immediate display without JavaScript<br \/>\n        if img.has_attr(&#8216;class&#8217;):<br \/>\n            img[&#8216;class&#8217;] = [c for c in img[&#8216;class&#8217;] if not c.startswith(&#8216;lazy&#8217;)]<\/p>\n<p>    # Process links (<a> tags) within the article content<br \/>\n    for a_tag in article_content.find_all(&#8216;a&#8217;):<br \/>\n        if a_tag.has_attr(&#8216;href&#8217;):<br \/>\n            href = a_tag[&#8216;href&#8217;]<br \/>\n            # Convert relative &#8216;href&#8217; URLs to absolute, but ignore internal anchor links (#&#8230;)<br \/>\n            if href and not urlparse(href).netloc and not href.startswith(&#8216;#&#8217;):<br \/>\n                absolute_href = urljoin(base_url, href)<br \/>\n                a_tag[&#8216;href&#8217;] = absolute_href<\/p>\n<p>    # Return the modified HTML content of the article<br \/>\n    return str(article_content)<\/p>\n<p># The URL provided by the user<br \/>\nuser_url = &#8220;https:\/\/smittenkitchen.com\/2025\/07\/burrata-with-crushed-cherries-and-pistachios\/#comment-2739128&#8221;<\/p>\n<p># Remove the comment anchor from the URL to get the base article URL<br \/>\nparsed_url = urlparse(user_url)<br \/>\narticle_base_url = parsed_url.scheme + &#8220;:\/\/&#8221; + parsed_url.netloc + parsed_url.path<\/p>\n<p># Get the processed HTML content<br \/>\nfinal_article_html = get_full_content_html(article_base_url)<\/p>\n<p># Print the final article HTML without any additional explanation<br \/>\nprint(final_article_html)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are these sweet or tart cherries??? It\u2019s almost tart cherry picking time in Door County (in Wisconsin). version ai : python import requests from bs4 import BeautifulSoup from urllib.parse import urljoin, urlparse def get_full_content_html(article_url: str) -> str: &#8220;&#8221;&#8221; Fetches the HTML content from the given URL, extracts the main article content, makes relative image and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-2621","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-uncategorized"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.6 (Yoast SEO v26.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>By: Mary - cupcake recipe<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"By: Mary\" \/>\n<meta property=\"og:description\" content=\"Are these sweet or tart cherries??? It\u2019s almost tart cherry picking time in Door County (in Wisconsin). version ai : python import requests from bs4 import BeautifulSoup from urllib.parse import urljoin, urlparse def get_full_content_html(article_url: str) -&gt; str: &#8220;&#8221;&#8221; Fetches the HTML content from the given URL, extracts the main article content, makes relative image and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cupcakerecipe.net\/?p=2621\" \/>\n<meta property=\"og:site_name\" content=\"cupcake recipe\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-07T01:48:51+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/?p=2621#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.cupcakerecipe.net\/?p=2621\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/eeb0f97aec73d7100df65b40b182044d\"},\"headline\":\"By: Mary\",\"datePublished\":\"2026-07-07T01:48:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.cupcakerecipe.net\/?p=2621\"},\"wordCount\":721,\"commentCount\":0,\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.cupcakerecipe.net\/?p=2621#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/?p=2621\",\"url\":\"https:\/\/www.cupcakerecipe.net\/?p=2621\",\"name\":\"By: Mary - cupcake recipe\",\"isPartOf\":{\"@id\":\"https:\/\/www.cupcakerecipe.net\/#website\"},\"datePublished\":\"2026-07-07T01:48:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/eeb0f97aec73d7100df65b40b182044d\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.cupcakerecipe.net\/?p=2621#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cupcakerecipe.net\/?p=2621\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/?p=2621#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.cupcakerecipe.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"By: Mary\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/#website\",\"url\":\"https:\/\/www.cupcakerecipe.net\/\",\"name\":\"cupcake recipe\",\"description\":\"Baking and dessert recipes for cupcakes, cakes, muffins, pies, and everything in between - from perfected classics to new and adventurous indulgences.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.cupcakerecipe.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/eeb0f97aec73d7100df65b40b182044d\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fa5a40e10f358e78b5b5a39b5fecc35f4c68f82c33a6fe8a71482b6be3838c69?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fa5a40e10f358e78b5b5a39b5fecc35f4c68f82c33a6fe8a71482b6be3838c69?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/cupcakerecipe.net\"],\"url\":\"https:\/\/www.cupcakerecipe.net\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"By: Mary - cupcake recipe","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"By: Mary","og_description":"Are these sweet or tart cherries??? It\u2019s almost tart cherry picking time in Door County (in Wisconsin). version ai : python import requests from bs4 import BeautifulSoup from urllib.parse import urljoin, urlparse def get_full_content_html(article_url: str) -> str: &#8220;&#8221;&#8221; Fetches the HTML content from the given URL, extracts the main article content, makes relative image and [&hellip;]","og_url":"https:\/\/www.cupcakerecipe.net\/?p=2621","og_site_name":"cupcake recipe","article_published_time":"2026-07-07T01:48:51+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cupcakerecipe.net\/?p=2621#article","isPartOf":{"@id":"https:\/\/www.cupcakerecipe.net\/?p=2621"},"author":{"name":"admin","@id":"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/eeb0f97aec73d7100df65b40b182044d"},"headline":"By: Mary","datePublished":"2026-07-07T01:48:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cupcakerecipe.net\/?p=2621"},"wordCount":721,"commentCount":0,"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.cupcakerecipe.net\/?p=2621#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.cupcakerecipe.net\/?p=2621","url":"https:\/\/www.cupcakerecipe.net\/?p=2621","name":"By: Mary - cupcake recipe","isPartOf":{"@id":"https:\/\/www.cupcakerecipe.net\/#website"},"datePublished":"2026-07-07T01:48:51+00:00","author":{"@id":"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/eeb0f97aec73d7100df65b40b182044d"},"breadcrumb":{"@id":"https:\/\/www.cupcakerecipe.net\/?p=2621#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cupcakerecipe.net\/?p=2621"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.cupcakerecipe.net\/?p=2621#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cupcakerecipe.net\/"},{"@type":"ListItem","position":2,"name":"By: Mary"}]},{"@type":"WebSite","@id":"https:\/\/www.cupcakerecipe.net\/#website","url":"https:\/\/www.cupcakerecipe.net\/","name":"cupcake recipe","description":"Baking and dessert recipes for cupcakes, cakes, muffins, pies, and everything in between - from perfected classics to new and adventurous indulgences.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cupcakerecipe.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/eeb0f97aec73d7100df65b40b182044d","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cupcakerecipe.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fa5a40e10f358e78b5b5a39b5fecc35f4c68f82c33a6fe8a71482b6be3838c69?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fa5a40e10f358e78b5b5a39b5fecc35f4c68f82c33a6fe8a71482b6be3838c69?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/cupcakerecipe.net"],"url":"https:\/\/www.cupcakerecipe.net\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=\/wp\/v2\/posts\/2621","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2621"}],"version-history":[{"count":0,"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=\/wp\/v2\/posts\/2621\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cupcakerecipe.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}