I have the following Python code that runs fine from my computer:
>>> from requests import get
>>> response = get("https://fiis.com.br/btal11/")
>>> response
<Response [403]>
>>> response = get("https://fiis.com.br/btal11/", headers={'User-agent': 'Mozilla/5.0'})
>>> response
<Response [200]>
If I simply add a user-agent header, I'm able to get the html page content. However, with the equivalent JS code on google Apps Script that doesn't work:
function GORDON(input) {
var url = "https://fiis.com.br/btal11/";
var options = {
muteHttpExceptions: true,
headers: {"User-agent": "Mozilla/5.0"},
};
var response = UrlFetchApp.fetch(url, options);
console.log(response.getContentText());
//var something = HtmlService.parse(response.getContentText());
}
and the result seems to be a challenge from Cloudflare to be solved:
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Just a moment...</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
</head>
<body class="no-js">
<div class="main-wrapper" role="main">
<div class="main-content">
<h1 class="zone-name-title h1">
<img class="heading-favicon" src="/favicon.ico" alt="Icon for fiis.com.br"
onerror="this.onerror=null;this.parentNode.removeChild(this)">
fiis.com.br
</h1>
<h2 class="h2" id="challenge-running">
Checking if the site connection is secure
</h2>
<noscript>
<div id="challenge-error-title">
<div class="h2">
<span class="icon-wrapper">
<div class="heading-icon warning-icon"></div>
</span>
<span id="challenge-error-text">
Enable JavaScript and cookies to continue
</span>
</div>
</div>
</noscript>
<div id="trk_jschal_js" style="display:none;background-image:url('/cdn-cgi/images/trace/managed/nojs/transparent.gif?ray=79c3f9c65b60e3b6')"></div>
<div id="challenge-body-text" class="core-msg spacer">
fiis.com.br needs to review the security of your connection before proceeding.
</div>
<form id="challenge-form" action="/btal11/?__cf_chl_f_tk=1lWKKYirqW.UmES1h5ANk6aNER4buUV9BvandjshiQU-1676861855-0-gaNycGzNCHs" method="POST" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="md"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>
</div>
</div>
<script>
(function(){
window._cf_chl_opt={
cvId: '2',
cZone: 'fiis.com.br',
cType: 'managed',
cNounce: '97809',
cRay: '79c3f9c65b60e3b6',
cHash: 'fc3e1644bceb435',
cUPMDTk: "\/btal11\/?__cf_chl_tk=1lWKKYirqW.UmES1h5ANk6aNER4buUV9BvandjshiQU-1676861855-0-gaNycGzNCHs",
cFPWv: 'g',
cTTimeMs: '1000',
cMTimeMs: '0',
cTplV: 4,
cTplB: 'cf',
cRq: {
ru: 'aHR0cHM6Ly9maWlzLmNvbS5ici9idGFsMTEv',
ra: 'TW96aWxsYS81LjAgKGNvbXBhdGlibGU7IEdvb2dsZS1BcHBzLVNjcmlwdDsgYmVhbnNlcnZlcjsgK2h0dHBzOi8vc2NyaXB0Lmdvb2dsZS5jb207IGlkOiBVQUVtZERkOHNNRzFSb0FJWGZTYnlsa2plUGwxdjhTdngwVUkp',
rm: 'R0VU',
d: 'K2hEeoWYs+sA9kntZPKxHqEaDzXqO9jP1DXfNo8U00z/HdqgsrqXN1eO/1L4D71PU/RaZfZMK/nfRS9wUs9n9wMZ7wa2+UCd+Wic1OqU3YV80fLAAQsnSPU7ZuJ5idh4DYvRqokv5w973lQ8O4+o5G9Tbp0TBj/G5oIVqE/HYaiQanIiyLhY6VoYkembTfL7ZFiePykhL/QWb9TRxI33+Iu8NCbRIfz5XQkDBoB0Lc2qftAyKY4kx40y7jiPLq1rOKk3be6zPJqXtYgbm0NE+2KuTRVy2gz9TN8LuBwy7sMi/uXEWXEh/8KDOUydo6rFxZ2ykmOVAhR6DiOj1CUBJvL71x01tHQLf0RBCbvrJ37who7mAkd8vNIQ3bBySUOeNTxVCxSDe1Erkx7EJjPzlmTDC9Ec9dyXddjMFV29k8B/8tTEOGtrNgsUenIOLd862lYHsqQTRdpGgQrdvgPxy/OOIBf93fM5A8CLogbDNLqYnVn8p0K8wvkk9Xjh9zc5mB3yR3KS0G/wz2S4BsLQEUb73vTj4fUDPK/QhxI3t4mWAk6kla2A7taIRA1myCoMbsQamtmqHB1396m+aubITHLeswV50zQ5si/qTqGlGSo+N5FYfBnUt96W/Cidhsxj76xDvYRC2GYaKJanN1h1IZnFb2B2Y4lfP0vkdy/qF6bp7upA1rMZ7ilLOu8LuOjb',
t: 'MTY3Njg2MTg1NS43MzUwMDA=',
m: 'SOz4uar/pXrmGBuSQIbY9tjFx2G6zirpJv2NyzOPmIM=',
i1: 'cIUbIpvI2YsvZRb//Yfdfw==',
i2: 'oC3KkuH26ng8Gt/f/kKHDw==',
zh: 'wcWWf/+obaYUptPh30e4072sXWiLjlPsWQnQS/2QxMI=',
uh: 'bllaG+Wp51WdmfI9k7pslxqw3F1/Neha3nrwdAjxueE=',
hh: '+MXXTc/rARCfTxK8igcq3MtDXAltL4ou2PYE97G16x4=',
}
};
var trkjs = document.createElement('img');
trkjs.setAttribute('src', '/cdn-cgi/images/trace/managed/js/transparent.gif?ray=79c3f9c65b60e3b6');
trkjs.setAttribute('alt', '');
trkjs.setAttribute('style', 'display: none');
document.body.appendChild(trkjs);
var cpo = document.createElement('script');
cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=79c3f9c65b60e3b6';
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, location.href.length - window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
if (window.history && window.history.replaceState) {
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
history.replaceState(null, null, "\/btal11\/?__cf_chl_rt_tk=1lWKKYirqW.UmES1h5ANk6aNER4buUV9BvandjshiQU-1676861855-0-gaNycGzNCHs" + window._cf_chl_opt.cOgUHash);
cpo.onload = function() {
history.replaceState(null, null, ogU);
};
}
document.getElementsByTagName('head')[0].appendChild(cpo);
}());
</script>
<div class="footer" role="contentinfo">
<div class="footer-inner">
<div class="clearfix diagnostic-wrapper">
<div class="ray-id">Ray ID: <code>79c3f9c65b60e3b6</code></div>
</div>
<div class="text-center" id="footer-text">Performance & security by <a rel="noopener noreferrer" href="https://www.cloudflare.com?utm_source=challenge&utm_campaign=m" target="_blank">Cloudflare</a></div>
</div>
</div>
</body>
</html>
What am I missing over here? Is there any way to bypass this challenge?
Related
I have 3 html files for this page. index.html, positive review page and negative review page. I want my JavaScript to redirect to the pages after clicking the emojis feedback and then the button. After clicking the button depending on the emojis clicked it should redirect to the negative review page if the emoji selected is neutral or unhappy and if the emoji selected is satisfied to redirect to the positive review page. I am new and stuck with the below code. The below code takes me back to the positive review page.
const sendButton = document.querySelector("#send");
const panelContainer = document.querySelector(".panel-container");
const ratings = document.querySelectorAll(".rating");
const experience = document.querySelectorAll("small");
sendButton.addEventListener("click", () => {
for (let i = 0; i < experience.length; i++) {
// console.log(experience[i].innerHTML);
if (
experience[i].innerHTML === "Unhappy" ||
experience[i].innerHTML === "Neutral"
) {
window.location = "negative_review.html";
} else {
window.location = "positive_review.html";
}
}
});
This is the index page only.
<!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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"
/>
<link rel="stylesheet" href="style.css" />
<title>Feedback</title>
</head>
<body>
<div id="panel" class="panel-container">
<h2>Welcome Text</h2>
<strong
>How was your experience <br />
with us?
</strong>
<div class="ratings-container">
<div class="rating">
<img
src="https://cdn-icons-png.flaticon.com/128/742/742752.png"
alt=""
/>
<small>Unhappy</small>
</div>
<div class="rating">
<img
src="https://cdn-icons-png.flaticon.com/128/725/725085.png"
alt=""
/>
<small>Neutral</small>
</div>
<div class="rating active">
<img
src="https://cdn-icons-png.flaticon.com/128/166/166549.png"
alt=""
/>
<small>Satisfied</small>
</div>
</div>
<form>
<label for="feedback">Please Tell Us About Your Experience</label>
<textarea name="" id="" maxlength="350" cols="30" rows="10"></textarea>
</form>
<button class="btn" id="send">Send Review</button>
</div>
<script src="script.js"></script>
</body>
</html>
It looks like the correct experience to use is the one surrounded by <div class="active">
sendButton.addEventListener("click", () => {
const experience = document.querySelector(".rating.active small");
if (
experience[i].innerHTML === "Unhappy" ||
experience[i].innerHTML === "Neutral"
) {
window.location = "negative_review.html";
} else {
window.location = "positive_review.html";
}
});
I don't know why code is executed right after loading the page. It should be executed after clicking the button (function onclick). Script is returning "koszt paliwa:0zł." The browser isn't returing any errors (.........................................................................................)
//javascript
var rodzaj = document.getElementById("rodzajPaliwa").value;
var ilosc = document.getElementById("litry").value;
function pierwszyrodzaj(){
ilosc *= 4
document.getElementById("koncowacenapaliwa").innerHTML = "koszt paliwa:" + ilosc + "zł";
}
function drugirodzaj(){
ilosc *= 3.5
document.getElementById("koncowacenapaliwa").innerHTML = "koszt paliwa:" + ilosc + "zł";
}
function inny(){
document.getElementById("koncowacenapaliwa").innerHTML = "koszt paliwa: 0zł";
}
function marcin (){
if(rodzaj = 1){
pierwszyrodzaj();
}else if(rodzaj = 2){
drugirodzaj();
}else{
inny();
}
}
document.getElementById("oblicz").onclick = marcin();
//html
<!DOCTYPE html>
<html lang="pl-PL">
<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">
<title>STACJA PALIW</title>
<link rel="stylesheet" href="styl3.css">
</head>
<body>
<div id="baner-lewy">
<h1>Stacja paliw</h1>
</div>
<div id="baner-prawy">
<a href="index.html">
<img src="home.png" alt="">
</a>
<a href="obliczenia.html">
<img src="znak.png" alt="">
</a>
</div>
<main>
<h3>Oblicz koszt paliwa</h3>
<label for="rodzajPaliwa">Rodzaj paliwa (1-benzyna, 2-olej napędowy): </label><br>
<input type="number" name="" id="rodzajPaliwa"><br><br>
<label for="litry">Ile litrów: </label><br>
<input type="number" id="litry"><br>
<br>
<button id="oblicz" >OBLICZ</button>
</br>
<span id="koncowacenapaliwa"></span>
<script src="skrypt.js"></script>
</main>
<div id="blok-lewy">
Pobierz kwerendy
</div>
<div id="blok-prawy">
<img src="samochod.png" alt="samochód">
</div>
<footer id="">
<p>© Stronę wykonał: Jan Kupczyk 4TID</p>
</footer>
</body>
</html>
I am trying to scrape products from mediamarkt site with Colly. Here is my code:
func WebScraper(allowedDomain string, page string, htmlElement string, htmlTag string) {
/*
Order in which Collector's callbacks are executed in:
1. OnRequest -> Called before a request
2. OnError -> Called if error occured durig the request
3. OnResponse -> Called after response received
4. OnHTML -> Called right after OnResponse if the received content is HTML
5. OnXML -> Called right after OnHTML if the recieved content is HTML or XML
6. Scraped -> Called after OnXML callback
*/
c := colly.NewCollector(
// MaxDepth is 2, so only the links on the scraped page
// and links on those pages are visited
colly.AllowedDomains(allowedDomain),
colly.MaxDepth(2),
colly.Async(true),
)
// Limit the maximum parallelism to 2
// This is necessary if the goroutines are dynamically
// created to control the limit of simultaneous requests.
//
// Parallelism can be controlled also by spawning fixed
// number of go routines.
c.Limit(&colly.LimitRule{DomainGlob: "*", Parallelism: 2})
// Step 2. Perform some logic before REQUEST Is made
c.OnRequest(func(r *colly.Request) {
app.InfoLog.Println("Visiting ", r.URL.String())
})
// Step 2.1. If errror occurred during the request, handle it!
c.OnError(func(r *colly.Response, err error) {
app.ErrorLog.Println("Request URL: ", r.Request.URL, " failed with response: ", r, "\nError: ", err)
})
// On every a element which has href attribute call callback
c.OnHTML(htmlElement, func(e *colly.HTMLElement) {
app.InfoLog.Println(e.ChildText(htmlTag))
})
c.Visit(page)
// Wait until threads are finished
c.Wait()
}
I've already tried scraping Wikipedia and some other sites, and it works. But here, I am getting 403 Forbidden error. Here is HEADER from RESPONSE:
Permissions-Policy : [accelerometer=(),autoplay=(),camera=(),clipboard-read=(),clipboard-write=(),fullscreen=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()]
Expires : [Thu, 01 Jan 1970 00:00:01 GMT]
Set-Cookie : [__cf_bm=eEhiHiAsyTUuG7Ra4_rGhBWBHGxP_FWphwxEIl66hW8-1654161057-0-Aef4Vr6ypA0zr8CVP66c2x9X1s+vUcusYPkMqJR3MhpLt/FxMHi+GXMD0+YEcb2L/cLC6RVhgROG9gOvXVTjQMIYUjwyvfi1/hFvAPthwzC/; path=/; expires=Thu, 02-Jun-22 09:40:57 GMT; domain=.mediamarkt.de; HttpOnly; Secure; SameSite=None]
Vary : [Accept-Encoding]
Date : [Thu, 02 Jun 2022 09:10:57 GMT]
Expect-Ct : [max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"]
Content-Type : [text/html; charset=UTF-8]
Cache-Control : [private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0]
Server : [cloudflare]
Cf-Ray : [714f0f0e3b881c23-SOF]
X-Frame-Options : [SAMEORIGIN]
Strict-Transport-Security : [max-age=15897600]
X-We-Are-Hiring : [We appreciate developers that love to explore what goes on under the hood of software. Apply now at https://careers.mediamarktsaturn.com/MediaMarktSaturn!]
And here is the Body of the RESPONSE:
<!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 http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" />
<!--[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: "41590",
cRay: "714f0f0e3b881c23",
cHash: "7549f8b7d78a2a4",
cUPMDTk: "\/de\/category\/smartphones-579.html?__cf_chl_tk=PrWxKIbQcP5Dh7keed1nL5yIqzx2FEiIyMvDz_3jTp0-1654161057-0-gaNycGzNBqU",
cFPWv: "g",
cTTimeMs: "1000",
cLt: "n",
cRq: {
ru: "aHR0cHM6Ly93d3cubWVkaWFtYXJrdC5kZS9kZS9jYXRlZ29yeS9zbWFydHBob25lcy01NzkuaHRtbA==",
ra: "Y29sbHkgLSBodHRwczovL2dpdGh1Yi5jb20vZ29jb2xseS9jb2xseQ==",
rm: "R0VU",
d: "vr3pEux85BB4TszTDjAPScZq2oMqIA1GoFOPEjftlymNdbnhggazvYIWsXBQOTzYsqm6B1QxUgRJqK2CNemXc9VqLj70rk1vMXKFsNRn8eSkCfbX1bVvJbp+S3YSI+zdrPmzOiiq4gO2vWm5pOKlKc+7qmux89XYc1J0YnOprUgYdHNeayUheiiXkRqwPQqW/cY1+5C2IsPzqzcU7M7YCnWjenwMn1pjLFjMclUxEi6s/gu5lLTr8HSnalidGwSVexGj4SBqmKekU99FZqEtE5kJutfFoUEiwuEJmmo7QrYuWrXRfB80Fms3xVWa8J6Ga4M9cnJgv3PP9qRucyj01EtAlfkpx7coaUfTJue65CZcHA4SJcB7WqMHdaUVojdSFsc4UoCYGbnstK2lyuX+v6GAC2GGOtK23s8DcfcB/YJsCChlpkURsIfnGbzmfI5cQf5JqWkhnW6p1UG3oKs7bec/dUNKL+XJjRH0rvyvKFkMX6Ca/0FX00zR0a1WcxnXOhU1iZzQOR2U/ZrXvfE0jeFCRQ+OHvCd0Ncfosas5axWsibMU+MeasO+bYbG8hTjHgvG8+tFc0tYII+nbVWFp44k+mWOBIhKh951P8TAoLl1h4HO9+hxKdpjQGAtjeZJ39oc3daC5julK9RJOng8Hw==",
t: "MTY1NDE2MTA1Ni45OTkwMDA=",
m: "cZC1J0+WAKjb0r4I8GxqyYnUTcVqCk2O4D12RYxeP7Q=",
i1: "90OzQhzN+BROMhNBF2EFBw==",
i2: "grkPyoRifg7B+X0FEjpHHQ==",
zh: "q1ZR4e29hYz+cTx2o5UYJG1hFifFh0loDJNTfBOG7gU=",
uh: "DaHp0r0NTdLobcNE2+1UVaN6g6tbXcsPQKHJoB7xdZI=",
hh: "+dgxVyY+fQBum8yrY3Q9pqqEvjydD2WPU3jRaUrPF1o=",
}
};
}());
//]]>
</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" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
<div id="cf-error-details" class="cf-error-details-wrapper">
<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.mediamarkt.de</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 class="challenge-form managed-form" id="challenge-form" action="/de/category/smartphones-579.html?__cf_chl_f_tk=PrWxKIbQcP5Dh7keed1nL5yIqzx2FEiIyMvDz_3jTp0-1654161057-0-gaNycGzNBqU" method="POST" enctype="application/x-www-form-urlencoded">
<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 type="hidden" name="md" value="u0AdAefiQaOd5cct_8y26o7DHt3en_YcDPYT5F0ABUY-1654161057-0-ATANjzlyezjgr7F1BeHeI_j_uUY38_a79__nKHeOV0Dk2cJOfgMdCTl3WoYsPTD7L25TEyF0Zu27FsSj21OI2aeiNSKmAbPirtvQwqJkPR_knETzvfp75Sv1rnhXV_52btLnozXuVO3Y_z7ElYk1CZDJDEdTw8Eu-MLyEaxyZGJHxx9Tk58hP1NPpWzN98aAcbhY0L1Au8IvJiH8bVmaRlLhK2KDOcXgM7KFONTOuo5-vGZjUjtE4YbUadBFGqk8jIZTRrIXZmwIZNm7TiPlPBwAz8POM7Rw_uoL7THpV4QUctlXigEqRHrY4g-jLcJEW-uZZm2qVMpzbAFOQjJ6UvkY_RC25ZQ5L0MQr1Nnh32-OQZctZIhj8edoK1TZasOXT6u0bT5lOecpx2j82H8mF59qM_zfUbIs4H6wvEx0prqNpEu-4Z7_x1y_agGnVMtW-2OCpKPjcmn9j1-NZnZYdJbrqTzdn2j6qe-wnn3RuRSna8DnN-W7AQTCS4vn7uYc76FWB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QP1KRibF3ixAzObVKTlGmAWUQLdfrc98pHn8oDI1cpCWzrhrsdAQImLLMEO49lJQnmvWpF+lP8iULAiJG4pdsZ5dIelChc7f4W51l0bAUvL/2l/lJg7/qLxFd5PqJp8Jo7nzqbgibEvM8/55/A3wtT9WX0kJp2Da8Kez0UzrgKeAb3VdGVrHwr+k1eJ4o3fI/RBesr/aWkbgjk4EM8itKypPg/c1Ejd9h/Kn89EpeJPtgz7t+vxDyH47kzmR0L9+gWOd5UBvVel/KzwxAxpuO0fw/tNYbEO0vJ2A3NWThWuS2g34K60w+y+Tp/TrNw/yrQH6wVUUsYESQCc2ZLkt8aVRPR30GuKuC9Zjaj8C8g3ywF5EDvFPYm9ZSPjayGyW3magUchBTngl9HJTiAADmSJB8sJfFWWNVJzKP8e7QRYdGbZzy+EiKzEUN61jWlCKlhFKFIwZlCZBIQ+TYL4+ukePHWoUgttIef21cFjy/ydCoznkJDPtceQDPNyCJZHBv2ljXGJ/IpPZ3CcLW9mAVOdjorEitBUY5ObbZTnpgFelrEKo9SVuE4tSawF7ba0TBcUR7yQXKcB6xmrsdlpn0Bp2Ki7rm8XnIGcK34U2+SQ2FrVaBEHTWW3vFWcdyfQmPPoD8BQo/to3Vt3Lz3K2RC8Ugh6bDzzD61z+6d1iWJ2qIyostZIvVQoPwNqdhYrWw9eBF4DF4COCxIoA16S9TLaEqSV+5e+fBfoRVw+jmsi0qRWkYbtBI0imU7f99EEIdP4y6sz+3LeHLUufXvHHWZoT2URjpCZSXJfhnYYg77qSZbIDX5z0RcnBpGBjiISfAwpfUpwp1SPe5fqB0rka6hvGektNSI+YgSPsI8mfH4CNh2dnaxN0OJzj64zaEWKJYrG3Jzhmip7RBJ7v7utJqqLQu6EWIfJ2b8vV314ucEgB9ORIjARY0Zb/Lx7/Jzrt4wvlsuEhySPHb7TylWO1Gyra">
<input type="hidden" name="vc" value="22dd9a5e4ec44559e78aa0e010d110ca">
<noscript id="cf-captcha-bookmark" class="cf-captcha-info">
<h1 data-translate="turn_on_js" style="color:#bd2426;">Please turn JavaScript on and reload the page.</h1>
</noscript>
<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>
<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=714f0f0e3b881c23')"></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=714f0f0e3b881c23");
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/g/orchestrate/managed/v1?ray=714f0f0e3b881c23";
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, "\/de\/category\/smartphones-579.html?__cf_chl_rt_tk=PrWxKIbQcP5Dh7keed1nL5yIqzx2FEiIyMvDz_3jTp0-1654161057-0-gaNycGzNBqU" + 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">714f0f0e3b881c23</strong></span>
<span class="cf-footer-separator sm:hidden">•</span>
<span class="cf-footer-item sm:block sm:mb-1"><span>Your IP</span>: 178.221.155.142</span>
<span class="cf-footer-separator sm:hidden">•</span>
<span class="cf-footer-item sm:block sm:mb-1"><span>Performance & security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing" id="brand_link" target="_blank">Cloudflare</a></span>
</p>
</div><!-- /.error-footer -->
</div>
</div>
<script>
window._cf_translation = {};
</script>
</body>
</html>
It looks like some sort of CAPTCHA or JS issue, but I cannot figure out how to avoid it. Any advice?
I'm trying to implement a Livesearch list onto a page where it takes an array and its objects and by using the search box, will filter matches and only show match of the search term,
The issue I'm having is that when looping through the array items using a forEach and trying to append the results to the DOM,
jQuery is Not defined
Essentially the code should grab the array, loop through the array, grab the building names and append each to the .list DIV as h4 items.
//testItemsArray
//array will contain objects used in the mockup for a livesearch function on the map pages.
var testItemsArray = [{
id: '1',
building: 'building1'
}, {
id: '2',
building: 'building2'
}, {
id: '3',
building: 'building3'
}, {
id: '4',
building: 'building4'
}, {
id: '5',
building: 'building5'
}];
(function($) {
$search = $('#searchbox'); // This is used for the filter input field
var buildingList = '',
buildingh4 = '';
testItemsArray.forEach(function(buildings) {
buildingh4 = "<h4>" + buildings.building + "</h4>";
buildingList += buildingh4
$('.list').html(buildingList);
});
}(jQuery));
<html lang="en">
<head>
<script src="./js/list.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/main.css">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Main Page</title>
</head>
<body>
<div class="container" id="search">
<header class="header">
<h1>University Of Lincoln Map Search</h1>
<h2></h2>
</header>
<div class="logo">
<p>This page is to be used for the locating of campus buildings and rooms</p>
</div>
<div class="info">
<div class="list">
********THIS IS WHERE I WANT ALL ITEMS TO DISPLAY** *****
</div>
</div>
<div class="key">
<div class="key-bg"></div>
<div class="key-text"><span><h2>Find the room you are looking for</h2></span></div>
<hr>
</div>
<div class="footer">
<p>map</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</body>
</html>
You should place this line of code before closing the body tag. Instead of using IIFE, use document.ready
In your code, you put your list.js before jquery.min.js, that's why you get jQuery is undefined error.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="./js/list.js"></script>
</body>
var testItemsArray = [{
id: '1',
building: 'building1'
}, {
id: '2',
building: 'building2'
}, {
id: '3',
building: 'building3'
}, {
id: '4',
building: 'building4'
}, {
id: '5',
building: 'building5'
}];
$(document).ready(function() {
$search = $('#searchbox'); // This is used for the filter input field
var buildingList = '',
buildingh4 = '';
testItemsArray.forEach(function(buildings) {
buildingh4 = "<h4>" + buildings.building + "</h4>";
buildingList += buildingh4
$('.list').html(buildingList);
});
});
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/main.css">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Main Page</title>
</head>
<body>
<div class="container" id="search">
<header class="header">
<h1>University Of Lincoln Map Search</h1>
<h2></h2>
</header>
<div class="logo">
<p>This page is to be used for the locating of campus buildings and rooms</p>
</div>
<div class="info">
<div class="list">
********THIS IS WHERE I WANT ALL ITEMS TO DISPLAY** *****
</div>
</div>
<div class="key">
<div class="key-bg"></div>
<div class="key-text"><span><h2>Find the room you are looking for</h2></span></div>
<hr>
</div>
<div class="footer">
<p>map</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="./js/list.js"></script>
</body>
</html>
Put your js reference that is
<!-- listJS cdn link-->
<script src="./js/list.js"></script>
After Jquery library reference that is below
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
You should have a reference to your Jquery library.
// IIFE - Immediately Invoked Function Expression
(function($, window, document) {
// The $ is now locally scoped
// The rest of your code goes here!
}(window.jQuery, window, document));
// The global jQuery object is passed as a parameter
Check here for references
The following code below is supposed to work as follows, the user is suppose to input a URL, Proxy IP & Proxy port once they click "test" it would grab the response code and replace the html h5 "awaiting test" with the new status code text. I made another version of this same exact script and it worked via client but when you run via electron app and click test button all you get is an error how do I get the button "test" to execute the script? Any help would be greatly appreciated.
Index HTML
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Simple Tester</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/semantic.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/semantic.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 id="header">Simple Tester v1.00</h1>
<div class="content">
<div class="proxytesturls">
<h3 id="url" style="color:#4a04de;" >Site URL:</h3>
<div class="ui large input">
<input type="text" placeholder="Google.com" id="siteurltext">
</div>
</div>
<div class="proxyip">
<h3 id="ip" style="color:#4a04de;">Proxy IP:</h3>
<div class="ui large input" id="proxyinput">
<input type="text" placeholder="1.1.1.1" id="proxyipinput">
</div>
</div>
<div class="proxyport">
<h3 id="port" style="color:#4a04de;">Proxy Port:</h3>
<div class="ui large input">
<input type="text" placeholder="8080" id="proxyportinput">
</div>
</div>
<input type="button" id="btnclick" value="test" onclick="pingProxy();">
<div class="ui raised segment" id="logger">
<h2 style="color:#4a04de;" id="logstext">Logger</h2>
<h5 id="awaitingtest">Awaiting test...</h5>
</div>
</div>
<script src="tester.js" type="text/javascript"></script>
</body>
</html>
tester.js
const request = require('request');
var pingProxy = require('ping-proxy');
var url = document.getElementById("siteurltext").value;
var proxyip = document.getElementById("proxyipinput").value;
var proxyport = document.getElementById("proxyportinput").value;
pingProxy({
proxyHost: proxyip,
proxyPort: proxyport,
proxyTestUrl: 'https://', url
},
function (err, options, statuscode) {
if (statuscode == 407) {
document.getElementById('awaitingtest').innerHTML = ('Status: Proxy Authentication Required');
}
if (statuscode == 200) {
document.getElementById('awaitingtest').innerHTML = ('Status: Valid Proxy!');
}
if (statuscode == 403) {
document.getElementById('awaitingtest').innerHTML = ('Status: Banned Proxy!');
}
if (statuscode == 401) {
document.getElementById('awaitingtest').innerHTML = ('Status: Unauthorized!');
}
}
);
Main.js
const electron = require('electron')
const {app, BrowserWindow} = require('electron')
function createWindow () {
// Create the browser window.
win = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
win.loadFile('index.html')
}
app.on('ready', createWindow)
Errors:
Uncaught TypeError: callback is not a function
at pingProxyAsync (C:\Users***********\proxytester\node_modules\ping-proxy\ping-proxy.js:21)
at HTMLInputElement.onclick (index.html:37)
You may need to concatenate the proxyTestUrl. Replace the comma with a plus sign.
pingProxy({
proxyHost: proxyip,
proxyPort: proxyport,
proxyTestUrl: 'https://' + url
},