Что я получаю в питон скрипте при get запросе к api chat gpt?
Написал мини скрипт для взятия html из https://chat-gpt.org/chat. Но в браузере совершенно другой html код. Что мне за файл дает питон (я посмотрел, что он находится во вкладке "Источники" в консоли разработчика браузера)? Как мне из этого файла достать html код страницы?
import requests
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
header = {
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.2470 YaBrowser/23.11.0.2470 Yowser/2.5 Safari/537.36"
}
url = "https://chat-gpt.org/chat"
res = requests.get(url,headers=header).text
with open("html.html","w",encoding="utf-8") as f:
f.write(res)
Вот что выдает питон:
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns#">
<head>
<meta charset="utf-8">
<title>Chat GPT Online - AI Chatbot</title>
<link rel="shortcut icon" href="https://chat-gpt.org/favicon-32x32.png" type="image/png">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="Use ChatGPT online and without registration. Just provide the AI chatbot with any text prompt and get a detailed response from ChatGPT.">
<meta name="keywords" content="chatgpt, chat, gpt, ai, openai, chatbot, artificial, intelligence, online, free">
<meta property="og:title" content="Chat GPT Online - AI Chatbot">
<meta property="og:description" content="Use ChatGPT online and without registration. Just provide the AI chatbot with any text prompt and get a detailed response from ChatGPT.">
<meta property="og:locale" content="en">
<meta property="og:type" content="website">
<meta property="og:url" content="https://chat-gpt.org">
<meta property="og:site_name" content="Chat GPT Online - AI Chatbot">
<meta property="og:width" content="1024">
<meta property="og:height" content="1024">
<meta property="og:image" content="https://chat-gpt.org/assets/img/chatgpt.png">
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Chat GPT Online - AI Chatbot" />
<meta name="twitter:description" content="Use ChatGPT online and without registration. Just provide the AI chatbot with any text prompt and get a detailed response from ChatGPT." />
<meta name="twitter:image" content="https://chat-gpt.org/assets/img/chatgpt.png">
<meta name="csrf-token" content="dhPXZxvYRW5zYOwIqd1j409PsfU5Sl0fp2RDlnCP">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00af83">
<meta name="msapplication-TileColor" content="#2d2f40">
<meta name="theme-color" content="#343541">
<meta name="smartbanner:title" content="ChatGPT">
<meta name="smartbanner:price" content="FREE">
<meta name="smartbanner:price-suffix-apple" content=" - On the App Store">
<meta name="smartbanner:price-suffix-google" content=" - In Google Play">
<meta name="smartbanner:icon-apple" content="https://chat-gpt.org/assets/img/chatgpt-app.png">
<meta name="smartbanner:icon-google" content="https://chat-gpt.org/assets/img/chatgpt-app.png">
<meta name="smartbanner:button" content="VIEW">
<meta name="smartbanner:button-url-apple" content="">
<meta name="smartbanner:button-url-google" content="https://play.google.com/store/apps/details?id=com.appstation.chatgpt">
<meta name="smartbanner:enabled-platforms" content="">
<meta name="smartbanner:close-label" content="Close">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WV3TJZVNPE"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-WV3TJZVNPE');
</script>
<!-- multi-ad -->
<script>
function check() {
let total_attempts = 5;
let pause_attempt = 1000; // ms, 1000ms = 1s
let number_check = 0;
let sem_interval;
const check_ads = function() {
if(number_check >= total_attempts) {
clearInterval(sem_interval);
Array.from(document.querySelectorAll('ins.adsbygoogle')).forEach(function (button) {
button.remove();
});
window.yaContextCb = window.yaContextCb || [];
const script = document.createElement('script');
script.onload = function () {
let banners_used = [];
Array.from(document.querySelectorAll('.ads-yandex')).forEach(function (el) {
if(el.getAttribute('data-ad-status') == 'filled') {
count++;
}
const blockId = el.getAttribute('data-block');
const type = el.getAttribute('data-type');
const platform = el.getAttribute('data-platform');
const renderTo = `yandex_rtb_${blockId}`;
el.setAttribute('id', renderTo)
if(banners_used.includes(renderTo)) {
return;
}
banners_used.push(renderTo);
// window.yaContextCb.push(()=>{
// Ya.Context.AdvManager.render({blockId, renderTo});
// })
Ya.Context.AdvManager.render({blockId, renderTo, type, platform});
});
};
script.src = 'https://yandex.ru/ads/system/context.js';
document.head.appendChild(script); //or something of the likes
return;
}
if(adsbygoogle.loaded && _check_filled_google()) {
clearInterval(sem_interval);
return;
}
number_check++;
function _check_filled_google() {
let count = 0;
Array.from(document.querySelectorAll('.adsbygoogle')).forEach(function (el) {
if(el.getAttribute('data-ad-status') == 'filled') {
count++;
}
});
return count > 0;
}
};
sem_interval = setInterval(check_ads, pause_attempt);
}
check();
</script>
<style>
ins.adsbygoogle[data-ad-status="unfilled"] {display: none !important;}
</style>
<!-- /multi-ad -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7958472158675518" crossorigin="anonymous"></script>
<link href="https://chat-gpt.org/assets/chat/assets/index.css?v3.96" rel="stylesheet">
</head>
<body>
<div class="page">
<div class="page__wrapper">
<div id="root"></div>
<div id="modal-root"></div>
</div>
</div>
<script type="module" crossorigin src="https://chat-gpt.org/assets/chat/assets/index.js?v3.96"></script>
<script>(function(){var js = "window['__CF$cv$params']={r:'8326a42d6c5e03b8',t:'MTcwMjA1NTYzMC45OTcwMDA='};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
</html>