<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xmlns:tt="http://teletype.in/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Mr. Mody</title><generator>teletype.in</generator><description><![CDATA[Mr. Mody]]></description><image><url>https://img3.teletype.in/files/62/67/6267eeee-7d1c-4379-a274-f32ef8e0dfeb.png</url><title>Mr. Mody</title><link>https://teletype.in/@modykun380</link></image><link>https://teletype.in/@modykun380?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=modykun380</link><atom:link rel="self" type="application/rss+xml" href="https://teletype.in/rss/modykun380?offset=0"></atom:link><atom:link rel="next" type="application/rss+xml" href="https://teletype.in/rss/modykun380?offset=10"></atom:link><atom:link rel="search" type="application/opensearchdescription+xml" title="Teletype" href="https://teletype.in/opensearch.xml"></atom:link><pubDate>Tue, 26 May 2026 05:07:36 GMT</pubDate><lastBuildDate>Tue, 26 May 2026 05:07:36 GMT</lastBuildDate><item><guid isPermaLink="true">https://teletype.in/@modykun380/ArI1Ff3y99</guid><link>https://teletype.in/@modykun380/ArI1Ff3y99?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=modykun380</link><comments>https://teletype.in/@modykun380/ArI1Ff3y99?utm_source=teletype&amp;utm_medium=feed_rss&amp;utm_campaign=modykun380#comments</comments><dc:creator>modykun380</dc:creator><title>python code to get the source code for a spasific site in folder ☕</title><pubDate>Fri, 07 Feb 2025 17:56:56 GMT</pubDate><description><![CDATA[import requests
from bs4 import BeautifulSoup
import os]]></description><content:encoded><![CDATA[
  <p id="fzIo">import requests<br />from bs4 import BeautifulSoup<br />import os</p>
  <p id="Qicr">def get_source_code(url):<br /> try:<br /> response = requests.get(url)<br /> response.raise_for_status() # Raise an exception for HTTP errors<br /> return response.text<br /> except requests.exceptions.RequestException as e:<br /> print(f&quot;An error occurred: {e}&quot;)<br /> return None</p>
  <p id="HrkU">def save_file(content, file_path):<br /> with open(file_path, &#x27;w&#x27;, encoding=&#x27;utf-8&#x27;) as file:<br /> file.write(content)</p>
  <p id="clBo">def extract_and_save_resources(url):<br /> # Fetch the HTML content<br /> html_content = get_source_code(url)<br /> if not html_content:<br /> return</p>
  <p id="apzK"># Save the HTML content<br /> html_file_path = &#x27;index.html&#x27;<br /> save_file(html_content, html_file_path)<br /> print(f&quot;HTML content saved to {html_file_path}&quot;)</p>
  <p id="CjFb"># Parse the HTML content<br /> soup = BeautifulSoup(html_content, &#x27;html.parser&#x27;)</p>
  <p id="hZxt"># Extract and save CSS files<br /> for link in soup.find_all(&#x27;link&#x27;, rel=&#x27;stylesheet&#x27;):<br /> css_url = link.get(&#x27;href&#x27;)<br /> if css_url:<br /> css_content = get_source_code(css_url)<br /> if css_content:<br /> css_file_path = os.path.join(&#x27;css&#x27;, os.path.basename(css_url))<br /> os.makedirs(os.path.dirname(css_file_path), exist_ok=True)<br /> save_file(css_content, css_file_path)<br /> print(f&quot;CSS content saved to {css_file_path}&quot;)</p>
  <p id="I11i"># Extract and save JavaScript files<br /> for script in soup.find_all(&#x27;script&#x27;, src=True):<br /> js_url = script.get(&#x27;src&#x27;)<br /> if js_url:<br /> js_content = get_source_code(js_url)<br /> if js_content:<br /> js_file_path = os.path.join(&#x27;js&#x27;, os.path.basename(js_url))<br /> os.makedirs(os.path.dirname(js_file_path), exist_ok=True)<br /> save_file(js_content, js_file_path)<br /> print(f&quot;JS content saved to {js_file_path}&quot;)</p>
  <p id="tVe3"># Example usage<br />url = &#x27;<a href="https://example.com" target="_blank">https://example.com</a>&#x27;<br />extract_and_save_resources(url)</p>

]]></content:encoded></item></channel></rss>