https://gall.dcinside.com/mgallery/board/view/?id=thesingularity&no=401624&page=1
์คํAI ์์ ๋ชจ๋ํฐ๋ง ์ฝ๋ ์งฐ๋คhttps://gall.dcinside.com/mgallery/board/view/?id=thesingularity&no=401622&page=1 OpenAI์ ์์์ ๋ฐ๋ก ๋ณด๋ ๋ฒgall.dcinside.comfrom flask import Flask, jsonify, render_template_string
import requests
import hashlib
app = Flask(__name__)
# ์ฌ์ดํธ๋งต URL
https://openai.com/sitemap.xml# ๋ง์ง๋ง์ผ๋ก ํ์ธ๋ ์ฌ์ดํธ๋งต์ ํด์ ๋ฐ ๋ด์ฉ
last_sitemap_hash = ""
last_sitemap_content = ""
def fetch_sitemap():
"""Fetches the sitemap and returns its content."""
try:
response = requests.get(SITEMAP_URL)
response.raise_for_status()
return response.text
except requests.RequestException as e:
print(f"Error fetching the sitemap: {e}")
return None
def hash_content(content):
"""Returns a hash of the given content."""
return hashlib.md5(content.encode('utf-8')).hexdigest()
@app.route('/')
def home():
"""A home page with automatic sitemap change detection."""
return render_template_string("""
<html>
<head>
<title>OpenAI Sitemap Monitor</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
#log { margin-top: 20px; }
</style>
</head>
<body>
<h1>OpenAI Sitemap Monitor</h1>
<p>This page automatically checks for changes in the OpenAI sitemap every 30 seconds.</p>
<div id="log"></div>
<script>
var firstCheck = true;
function checkForChanges() {
$.get('/check-sitemap-change', function(data) {
var logEntry = document.createElement('p');
if (data.changed) {
if (!firstCheck) {
logEntry.innerHTML = 'Change detected at ' + new Date().toLocaleTimeString();
logEntry.style.color = 'green';
}
} else {
logEntry.innerHTML = 'No change at ' + new Date().toLocaleTimeString();
logEntry.style.color = 'gray';
}
document.getElementById('log').prepend(logEntry);
firstCheck = false;
});
}
// Check for changes every 30 seconds
setInterval(checkForChanges, 30000);
</script>
</body>
</html>
""")
@app.route('/check-sitemap-change', methods=['GET'])
def check_sitemap_change():
"""Checks if the sitemap has changed since the last check."""
global last_sitemap_hash, last_sitemap_content
sitemap_content = fetch_sitemap()
if sitemap_content:
current_hash = hash_content(sitemap_content)
if last_sitemap_hash and current_hash != last_sitemap_hash:
# Update the last known hash and content, and return that a change was detected
last_sitemap_hash = current_hash
last_sitemap_content = sitemap_content
return jsonify({"changed": True})
# Update the last known hash and content
last_sitemap_hash = current_hash
last_sitemap_content = sitemap_content
return jsonify({"changed": False})
else:
return jsonify({"error": "Unable to fetch sitemap"}), 500
if __name__ == '__main__':
app.run(debug=True)
๋ง๋ ๊ฑฐ์์ ๊ธฐ๋ฅ ํ๋์ฉ ์ข ๋ ์ถ๊ฐํด๋ฌ๋ผํ๋๊น ์์ฃผ ์ํด์ฃผ๋
ธ ใ
ใ
๋ก์ปฌ ํ์ด์ฌ์ผ๋ก ์คํํ๋ฉด ์๋๋ค
์คํAI ์ ์์ ๋์ค๋ฉด ๋ฐ๋ก ์ ์ ์๊ฒ ๋ ธ.
๋๊ฐ aws ํธ์คํ ๊น์ง ์ข ํด์ค๋ผ
๋ณธ๋ ๋ด๊ฐ ๊ตฌ์ํ๊ฑด ์ฑ์ผ๋ก ๋ง๋ค์ด์ ํด๋ํฐ์ ํธ์ฌ์๋ ๋์ฐ๋ ๊ฑฐ์ ์ง๊ธ์ฒ๋ผ ํ๋ฉด ํ์ด์ฌ ์ผฐ์๋๋ง ๊ฐ๋ฅํด์.. ๋ผ๋ถํฐ ๋ง๋ค์ด๋ณผ๊ฒ
๊ฐ์ถ