Scrape image using CURL? - linux

I inspected this Manga Page and got this image link.
I tried using curl command to download the image but it returned html data instead.
Command i used : curl https://images.mangafreak.net/mangas/hajimete_no_gal/hajimete_no_gal_45/hajimete_no_gal_45_18.jpg
Returned data :
<!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, maximum-scale=1" />
<title>Entering Mangafreak...</title>
<style type="text/css" >h1,p{color:#404040;text-align:center}#myDiv,#myDiv1,h1,p{text-align:center}body,html{width:100%;height:100%;margin:0;padding:0}body{background-color:#fff;font-family:Helvetica,Arial,sans-serif;font-size:100%}h1{font-size:1.5em}p{font-size:1em;margin:10px 0 0}#myDiv1{display:none}img{max-width:100%;height:auto;width:auto}</style>
<script type="text/javascript">
//<![CDATA[
(function(){
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 a = document.getElementById('cf-content');a.style.display = 'block';
setTimeout(function(){
var s,t,o,p,b,r,e,a,k,i,n,g,f, xDznyGO={"wN":+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![]))/+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]))};
g = String.fromCharCode;
o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
e = function(s) {
s += "==".slice(2 - (s.length & 3));
var bm, r = "", r1, r2, i = 0;
for (; i < s.length;) {
bm = o.indexOf(s.charAt(i++)) << 18 | o.indexOf(s.charAt(i++)) << 12
| (r1 = o.indexOf(s.charAt(i++))) << 6 | (r2 = o.indexOf(s.charAt(i++)));
r += r1 === 64 ? g(bm >> 16 & 255)
: r2 === 64 ? g(bm >> 16 & 255, bm >> 8 & 255)
: g(bm >> 16 & 255, bm >> 8 & 255, bm & 255);
}
return r;
};
t = document.createElement('div');
t.innerHTML="<a href='/'>x</a>";
t = t.firstChild.href;r = t.match(/https?:\/\//)[0];
t = t.substr(r.length); t = t.substr(0,t.length-1);
a = document.getElementById('jschl-answer');
f = document.getElementById('challenge-form');
;xDznyGO.wN*=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![])+(+[])+(!+[]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]))/+((!+[]+!![]+[])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]));xDznyGO.wN-=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]))/+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![]+!![]+!![]));xDznyGO.wN+=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![])+(+[])+(!+[]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]))/+((!+[]+!![]+!![]+[])+(!+[]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]));xDznyGO.wN-=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]))/+((!+[]+!![]+[])+(!+[]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]));xDznyGO.wN-=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(+[])+(+[])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]))/+((!+[]+!![]+!![]+[])+(!+[]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]));xDznyGO.wN-=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]))/+((!+[]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]));xDznyGO.wN-=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![])+(+[])+(!+[]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]))/+((!+[]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(+[]));xDznyGO.wN*=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]))/+((!+[]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]));a.value = (+xDznyGO.wN + t.length).toFixed(10); '; 121'
f.action += location.hash;
f.submit();
}, 4000);
}, false);
})();
//]]>
</script>
</head>
<body>
<table width="100%" height="100%" cellpadding="20">
<td align="center" valign="middle">
<div id="myDiv1"><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>
<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> mangafreak.net.</h1>
<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">Please allow up to 5 seconds…</p>
</div>
<form id="challenge-form" action="/cdn-cgi/l/chk_jschl" method="get">
<input type="hidden" name="s" value="6977b7c5689e60d0637e781cc9d42b048667542c-1564646132-1800-AT6wnbzFcJ7/IWIZ7MeJA7CHxZgNogpaJiSlrZjpDR9uZt3xLsJEs3LJzVfvvdfvNDetfDL70qQB0SvIwtGURGtXqF8VwI7PTpj2eeDBPB273Ff3+X3mLUXPommEBIx+cI8i4HRVM0H2tPIdP98ZbNUmDKRFDoLsSU5rDYt9r1+fN7YY9OwXDQN8wgsNBR/lNbwn3Ugr2nFTQzNNBtCSIjU="></input>
<input type="hidden" name="jschl_vc" value="38d158d1174811116b7423d15274558d"/>
<input type="hidden" name="pass" value="1564646136.76-AFFAHwDTSK"/>
<input type="hidden" id="jschl-answer" name="jschl_answer"/>
</form>
</div>
</div>
<div id="myDiv">
<h1>Entering Mangafreak...</h1>
<img src="data:image/gif;charset=binary;base64,R0lGODlh9AGAAfYAAAAAAMvLy9vb2+zs7P7+/jw8PLOzs7y8vFNTU3t7e5ycnNjY1xMTE0REREtLS4uLi5SUlPT09A8QDxsbGysrK1hXV9PT0+Df3+jn5yAgHwkHBwcHCAwLCxAPDxcYFyAfHyQjIycoJzQ0NDk4N0BAP0hHR1BPT1BQT1xcXGRjY2xra3V1dYSDg6Ojo6ysrLCwr8TExMjIx+Tk5Ofn6PDw7zMzM3Nzc/j49wgIBwwMDHh3d6urqxwcHCMjI2xsa+Pj4w8PEBgYFx8gHygoJywrKzAvL1lYV1tbW2RkZGhoZ4ODg6Sko6inp7Cvr7i3t8C/v8TDw9DPz9TU0/Pz85SUk8PDwxISERgXFyUlJUA/P0REQ0hHRktLSlRUVF1dXWRkY2tra3Bvb3x8fISEhIiHh4yLi52dnaWlpbi4t+Tj4wgHBwwMCxQUFCoqKjw7O0NDQ0xLS1xbW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cSOHDp4f5/JpjPUjgAIfb3qsUQMRIps4eDIyuuOGZMmXDtnUiENFj8qNOE3dCEAlTg02MIO6wdPohh03QZMCkNgmjgI92nJK/QRNQRx2LpW+dHPnpqEqSLVqZfMmAZ49XqeqheQNTwI3QP/FJlUDR4+iBXDkyl3TA0EdPffWCm4UYYECBDwa6lWqxkZgQwNsKF4sds2bOXgeD948aECVOW8mU1bKo05aOzxGL17TRo4dc5wH/7hjo4Zo1UrrGvqRFzdlNnDoBEgbm5uAOnF6+F49R+UNBXGXL55oI3NxfDcEUIGjXPpiN1UI/UCQ1btevq5/XFd2Qw8dONHN77WxZxCeNvJVq+kRx+56YQMoAF9+o7kRwCB31FAegS+poYY7bMQjh3//AfODOm1k0M5IDM5VA1GCDGCHDwLx0A5J5aG4lIPuQMgGGzzE2EMPbbThhhtvICCHDXNQUcc16lUozA0diUNFAj7EAcf/jTXU2EMGMb64oTsuObiiQw4+uAaMbbzhwx31ERJBkVTMYYMPcsShZhxytOmDDzbYkMAcPVJBjR134FFFAHoI8MMAA0SAjJD5HCPoDXv88IMeAVSBxx12jEMFHXQmECeaba6p5o4J0PEjYM4wsg+gf0aAVqiEpmqJoREM8CegxKkqqyixzmrrrbjmquuuvPbq66/ABpvLD3XQUUWtjQyABx103KGZsL0KYANQb6RUyQB0dNcDHchCq2oECSimRhxBTlJFDRC1caC3vOrxBkSlVVJHfDzYwW6770IUR1SRDJBASfXeu2sENpTUQx3PMhJgdw+pK/CudjC8VBsJ2JNsljr4lQRHwg/L+oMct6nRhg/1lIqMq+DUYYMbtwEQb8e63hcUD24gwCOzZsqxTnwQreFDuTDfegMVqc3VIodKrTFh0AMTLR8PNiTE9K4D1MGybxLBYQfHU9u6kw1ttJw0DwgoAFvXvnq28kBIQ/RghG9UhxHa0A6Qx5FyIADHG2/AgUAcNlBRBdd0B+vNDwII0Kei/HYdCAA7">
<p>Please wait while we make things better for you.</p>
</div>
</td></table></body>
</html>
I don't understand why is this happening. Am i missing something? or does the https protocol has anything to do with it?
Please, any help will be appreciated :)

I'm not able to comment your post so I'm writing the reply. I wanted to do the same thing with PHP and curl. Seeing your post I decided to dig deeper.
I've just checked the HTML code and I think that it isn't the page's code that redirects you but rather it's the server. JS creates a timeout function that submits a form which contains hidden fields with encrypted data, I presume it's used on the server-side to determine where you should be redirected.

Related

How to login into a web with Python Requests module?

I've been reading about requests module and was trying a few different methods.
However, there is a problem when it comes to web authentication.
Testing site: http://testing-ground.scraping.pro/login
Username: admin
Password: 12345
Here is the sample code
>>> import requests, re
>>> url = 'http://testing-ground.scraping.pro/login'
>>> username = 'admin'
>>> password = '12345'
>>> requests.get(url)
<Response [200]>
Without authentication
>>> print(requests.get(url).text)
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Web Scraper Testing Ground</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/main.css">
<script src="/js/vendor/modernizr-2.6.1.min.js"></script>
<script src="/js/vendor/jquery-1.9.1.min.js"></script>
<script src="/js/vendor/jquery-ui-1.10.2.min.js"></script>
<script src="/js/plugins.js"></script>
<script src="/js/main.js"></script>
<link rel="stylesheet" href="/css/QapTcha.jquery.css" />
<script src="/js/QapTcha.jquery.js"></script>
<link rel="stylesheet" href="/fancy-captcha/captcha.css" />
<script src="/fancy-captcha/jquery.captcha.js"></script>
</head>
<body>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4436411-8']);
_gaq.push(['_setDomainName', 'extract-web-data.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. Upgrade your browser today or install Google Chrome Frame to better experience this site.</p>
<![endif]-->
<div id="topbar"></div>
<a href="/" style="text-decoration: none">
<div id="title">WEB SCRAPER TESTING GROUND</div>
<div id="logo"></div>
</a>
<div id="content">
<h1>LOGIN</h1>
<div id="caseinfo">Often in order to reach the desired information you need to be logged in to the website. Most of today's websites use so-called form-based authentication which implies sending user credentials using POST method, authenticating it on the server and storing user's session in a cookie.</p>
<p>This simple test shows scraper's ability to:</p>
<ol>
<li>Send user credentials via POST method</li>
<li>Receive, Keep and Return a session cookie</li>
<li>Process HTTP redirect (302)</li>
</ol>
<p>How to test:</p>
<ol>
<li>Enter <b>admin</b> and <b>12345</b> in the form below and press <b>Login</b></li>
<li>If you see <span class="success">WELCOME :)</span> then the user credentials were sent, the cookie was passed and HTTP redirect was processed</li>
<li>If you see <span class="error">ACCESS DENIED!</span> then either you entered wrong credentials or they were not sent to the server properly</li>
<li>If you see <span class="error">THE SESSION COOKIE IS MISSING OR HAS A WRONG VALUE!</span> then the user credentials were properly sent but the session cookie was not properly stored or passed</li>
<li>If you see <span class="success">REDIRECTING...</span> then the user credentials were properly sent but HTTP redirection was not processed</li>
<li>Click <b>GO BACK</b> to start again</li>
</ol>
</div>
<hr/>
<div id="case_login">
<h3>Please, login:</h3>
<form action="login?mode=login" method="POST">
<label for="usr">User name:</label>
<input id="usr" name="usr" type="text" placeholder="enter 'admin' here">
<label for="pwd">Password:</label>
<input id="pwd" name="pwd" type="text" placeholder="enter '12345' here">
<input type="submit" value="Login">
</form>
</div>
<br/><br/><br/>
</div>
</body>
</html>
>>>
With authentication
>>> print(requests.get(url, auth=(username, password)).text)
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Web Scraper Testing Ground</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/main.css">
<script src="/js/vendor/modernizr-2.6.1.min.js"></script>
<script src="/js/vendor/jquery-1.9.1.min.js"></script>
<script src="/js/vendor/jquery-ui-1.10.2.min.js"></script>
<script src="/js/plugins.js"></script>
<script src="/js/main.js"></script>
<link rel="stylesheet" href="/css/QapTcha.jquery.css" />
<script src="/js/QapTcha.jquery.js"></script>
<link rel="stylesheet" href="/fancy-captcha/captcha.css" />
<script src="/fancy-captcha/jquery.captcha.js"></script>
</head>
<body>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4436411-8']);
_gaq.push(['_setDomainName', 'extract-web-data.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. Upgrade your browser today or install Google Chrome Frame to better experience this site.</p>
<![endif]-->
<div id="topbar"></div>
<a href="/" style="text-decoration: none">
<div id="title">WEB SCRAPER TESTING GROUND</div>
<div id="logo"></div>
</a>
<div id="content">
<h1>LOGIN</h1>
<div id="caseinfo">Often in order to reach the desired information you need to be logged in to the website. Most of today's websites use so-called form-based authentication which implies sending user credentials using POST method, authenticating it on the server and storing user's session in a cookie.</p>
<p>This simple test shows scraper's ability to:</p>
<ol>
<li>Send user credentials via POST method</li>
<li>Receive, Keep and Return a session cookie</li>
<li>Process HTTP redirect (302)</li>
</ol>
<p>How to test:</p>
<ol>
<li>Enter <b>admin</b> and <b>12345</b> in the form below and press <b>Login</b></li>
<li>If you see <span class="success">WELCOME :)</span> then the user credentials were sent, the cookie was passed and HTTP redirect was processed</li>
<li>If you see <span class="error">ACCESS DENIED!</span> then either you entered wrong credentials or they were not sent to the server properly</li>
<li>If you see <span class="error">THE SESSION COOKIE IS MISSING OR HAS A WRONG VALUE!</span> then the user credentials were properly sent but the session cookie was not properly stored or passed</li>
<li>If you see <span class="success">REDIRECTING...</span> then the user credentials were properly sent but HTTP redirection was not processed</li>
<li>Click <b>GO BACK</b> to start again</li>
</ol>
</div>
<hr/>
<div id="case_login">
<h3>Please, login:</h3>
<form action="login?mode=login" method="POST">
<label for="usr">User name:</label>
<input id="usr" name="usr" type="text" placeholder="enter 'admin' here">
<label for="pwd">Password:</label>
<input id="pwd" name="pwd" type="text" placeholder="enter '12345' here">
<input type="submit" value="Login">
</form>
</div>
<br/><br/><br/>
</div>
</body>
</html>
>>>
Since there is a web login form in the output, I believe the authentication didn't work as expected.
<h3>Please, login:</h3>
<form action="login?mode=login" method="POST">
<label for="usr">User name:</label>
<input id="usr" name="usr" type="text" placeholder="enter 'admin' here">
<label for="pwd">Password:</label>
<input id="pwd" name="pwd" type="text" placeholder="enter '12345' here">
<input type="submit" value="Login">
</form>
What's wrong in this case and what should I do to fix it?
You should do a post into where login page leads:
>>> import requests, re
>>> url = 'http://testing-ground.scraping.pro/login?mode=login'
>>> username = 'admin'
>>> password = '12345'
>>> requests.post(url, data={'usr':username, 'pwd':password})

Escape script to hide/reveal textarea

I need to make my button click to reveal the textarea so the user can choose between uploading either an image or a text message. I can see the hidden/visible element kicking in when I run the page but it doesn't remain in the new state. It immediately reverts back to whatever it was originally set as.
I'm guessing that I'm not escaping the script properly. Any thoughts?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Site Media</title>
</head>
<header id="headtitle">
</header>
<body>
<div id="PostContainer"><br>
<textarea id="textmessage" rows="7" cols="40" maxlength="280" placeholder="Enter message here..." width="100%" style="visibility: hidden"></textarea><br>
<form class="UploadButtonContainer">
<button id="textbutton" type="submit" name="submit" onclick="revealinput()" style="display: none;"></button>
<label for="textbutton" style="cursor: pointer;" ><img src="Images/AYE PING.png" width="30%" alt="Choose Text Post" >
</label>
</form>
<script>
function revealinput() {
var x = document.getElementById("textmessage");
if (x.style.visibility === "hidden") {
x.style.visibility = "visible";
} else {
x.style.visibility = "hidden";
}
}
</script>
</div>
</body>
</html>
The script didn't like the button being inside a tag. I changed it to a tag and it works now.

SendKeys in JavaScript HTML page using selenium VBA

I have a page with too much Javascript and there is a search box where I would like to use SendKeys to put some text. The search box id is ctl00_ContentPlaceHolder1_txtSearch but when trying to use it directly, I encountered an error.
.FindElementByXPath("//*[#id='ctl00_ContentPlaceHolder1_txtSearch']").SendKeys "1111"
Here's the HTML
<html xmlns="http://www.w3.org/1999/xhtml" style="" class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers no-applicationcache svg inlinesvg smil svgclippaths"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> البرامج الرقمية للتمكين المهني</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="الأكاديمية المهنية للمعلمين , مركز تميز محلي وإقليمي ودولي ، يضمن جودة منظومة التنمية المهنية المستدامة لأعضاء هيئة التعليم ، بشراكة فاعلة مع كليات التربية والمدارس والمؤسسات الأخرى ذات الصلة.">
<meta name="keywords" content="الأكاديمية المهنية للمعلمين, منصة التدريب عن بعد, البرامج الرقمية للتمكين المهني, كادر المعلم, ترقي المعلمين, نظام كادر المعلم, وزارة التربية والتعليم, تدريب اون لاين">
<meta name="author" content="pat.edu.eg">
<!-- Facebook and Twitter integration -->
<meta property="og:title" content="">
<meta property="og:image" content="">
<meta property="og:url" content="">
<meta property="og:site_name" content="">
<meta property="og:description" content="">
<meta name="twitter:title" content="">
<meta name="twitter:image" content="">
<meta name="twitter:url" content="">
<meta name="twitter:card" content="">
<!-- <link href="https://fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet"> -->
<!-- Animate.css -->
<link rel="stylesheet" href="assets/css/animate.css">
<!-- Icomoon Icon Fonts-->
<link rel="stylesheet" href="assets/css/icomoon.css">
<!-- Themify Icons-->
<link rel="stylesheet" href="assets/css/themify-icons.css">
<!-- Bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.css">
<!-- Magnific Popup -->
<link rel="stylesheet" href="assets/css/magnific-popup.css">
<!-- Owl Carousel -->
<link rel="stylesheet" href="assets/css/owl.carousel.min.css">
<link rel="stylesheet" href="assets/css/owl.theme.default.min.css">
<!-- Flexslider -->
<link rel="stylesheet" href="assets/css/flexslider.css">
<!-- Theme style -->
<link rel="stylesheet" href="assets/css/style.css">
<!-- Modernizr JS -->
<script src="assets/js/modernizr-2.6.2.min.js"></script>
<!-- FOR IE9 below -->
<!--[if lt IE 9]>
<script src="js/respond.min.js"></script>
<![endif]-->
<!-- أكواد حماية -->
<script type="text/javascript">
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
var isCtrl = false;
document.onkeyup=function(e)
{
if(e.which == 17)
isCtrl=false;
}
document.onkeyup=function(e)
{
if(e.which == 83)
isCtrl=false;
}
document.onkeydown=function(e)
{
if(e.which == 17)
isCtrl=true;
if((e.which == 85) || (e.which == 67) && isCtrl == true)
{
return false;
}
}
</script>
<script>
document.addEventListener("keydown", function(e) {
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
e.preventDefault();
}
}, false);
</script>
<script type="text/javascript">
shortcut={all_shortcuts:{},add:function(a,b,c){var d={type:"keydown",propagate:!1,disable_in_input:!1,target:document,keycode:!1};if(c)for(var e in d)"undefined"==typeof c[e]&&(c[e]=d[e]);else c=d;d=c.target,"string"==typeof c.target&&(d=document.getElementById(c.target)),a=a.toLowerCase(),e=function(d){d=d||window.event;if(c.disable_in_input){var e;d.target?e=d.target:d.srcElement&&(e=d.srcElement),3==e.nodeType&&(e=e.parentNode);if("INPUT"==e.tagName||"TEXTAREA"==e.tagName)return}d.keyCode?code=d.keyCode:d.which&&(code=d.which),e=String.fromCharCode(code).toLowerCase(),188==code&&(e=","),190==code&&(e=".");var f=a.split("+"),g=0,h={"`":"~",1:"!",2:"#",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|"},i={esc:27,escape:27,tab:9,space:32,"return":13,enter:13,backspace:8,scrolllock:145,scroll_lock:145,scroll:145,capslock:20,caps_lock:20,caps:20,numlock:144,num_lock:144,num:144,pause:19,"break":19,insert:45,home:36,"delete":46,end:35,pageup:33,page_up:33,pu:33,pagedown:34,page_down:34,pd:34,left:37,up:38,right:39,down:40,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},j=!1,l=!1,m=!1,n=!1,o=!1,p=!1,q=!1,r=!1;d.ctrlKey&&(n=!0),d.shiftKey&&(l=!0),d.altKey&&(p=!0),d.metaKey&&(r=!0);for(var s=0;k=f[s],s<f.length;s++)"ctrl"==k||"control"==k?(g++,m=!0):"shift"==k?(g++,j=!0):"alt"==k?(g++,o=!0):"meta"==k?(g++,q=!0):1<k.length?i[k]==code&&g++:c.keycode?c.keycode==code&&g++:e==k?g++:h[e]&&d.shiftKey&&(e=h[e],e==k&&g++);if(g==f.length&&n==m&&l==j&&p==o&&r==q&&(b(d),!c.propagate))return d.cancelBubble=!0,d.returnValue=!1,d.stopPropagation&&(d.stopPropagation(),d.preventDefault()),!1},this.all_shortcuts[a]={callback:e,target:d,event:c.type},d.addEventListener?d.addEventListener(c.type,e,!1):d.attachEvent?d.attachEvent("on"+c.type,e):d["on"+c.type]=e},remove:function(a){var a=a.toLowerCase(),b=this.all_shortcuts[a];delete this.all_shortcuts[a];if(b){var a=b.event,c=b.target,b=b.callback;c.detachEvent?c.detachEvent("on"+a,b):c.removeEventListener?c.removeEventListener(a,b,!1):c["on"+a]=!1}}},;
</script>
<script language="JavaScript">
window.onload = function () {
document.addEventListener("contextmenu", function (e) {
e.preventDefault();
}, false);
document.addEventListener("keydown", function (e) {
//document.onkeydown = function(e) {
// "I" key
if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {
disabledEvent(e);
}
// "J" key
if (e.ctrlKey && e.shiftKey && e.keyCode == 74) {
disabledEvent(e);
}
// "S" key + macOS
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
disabledEvent(e);
}
// "U" key
if (e.ctrlKey && e.keyCode == 85) {
disabledEvent(e);
}
// "F12" key
if (event.keyCode == 123) {
disabledEvent(e);
}
// "print" key
if (event.keyCode == 80) {
disabledEvent(e);
}
// "back" key
if (event.keyCode == 16) {
disabledEvent(e);
}
}, false);
function disabledEvent(e) {
if (e.stopPropagation) {
e.stopPropagation();
} else if (window.event) {
window.event.cancelBubble = true;
}
e.preventDefault();
return false;
}
}
//edit: removed ";" from last "}" because of javascript error
</script>
<!-- نهاية أكواد الحماية -->
</head>
<body onbeforeprint="onbeforeprint()" onafterprint="onafterprint()" onselectstart="return false" oncontextmenu="return false" onkeydown="return true;" onmousedown="return true;"><i></i><div id="gtco-offcanvas"><ul>
<li>خروج</li>
</ul></div>
<!-- أكواد حماية -->
<!-- نهاية أكواد الحماية -->
<!-- jQuery -->
<script src="assets/js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="assets/js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script src="assets/js/jquery.waypoints.min.js"></script>
<!-- Carousel -->
<script src="assets/js/owl.carousel.min.js"></script>
<!-- countTo -->
<script src="assets/js/jquery.countTo.js"></script>
<!-- Flexslider -->
<script src="assets/js/jquery.flexslider-min.js"></script>
<!-- Magnific Popup -->
<script src="assets/js/jquery.magnific-popup.min.js"></script>
<script src="assets/js/magnific-popup-options.js"></script>
<!-- Main -->
<script src="assets/js/main.js"></script>
<div class="gtco-loader" style="display: none;"></div>
<div id="page">
<!-------------------------------------------------------- Content Here ------------------------------------------->
<form name="aspnetForm" method="post" action="search.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTExNDI3MTk4MDRkZMiC3ceJDBMSb/hvOzfoo1Ps81e/">
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=ft_DCi-yGXrSm5-RC0zWVdeA5nhykesM_HFiFg9Bdn9rUthWc0jbZpTp5HdlmUge2tXyj_sn-_9j8ZpflhpUQ40fHBg1&t=636284381597151108" type="text/javascript"></script>
<script src="/WebResource.axd?d=zZ7eInuoGtXVXhG436dX9AySvq4rdhbrhYzcgxr10UDlZ0USkDe6DoY1HPcsXhPUj6kKnwkfxeJDPnwBmBkYnsou7IE1&t=636284381597151108" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>
<div>
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="5D3B39A4">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwLlr+XcAwKnpt8nAve684YCAX7xuYxu9gxA+eUqV0T9dl+AfGk=">
</div>
<nav class="gtco-nav" role="navigation">
<div class="gtco-container">
<div class="row">
<div class="col-sm-2 col-xs-12">
<div id="gtco-logo"><img src="assets/images/logo-up.png" alt="منصة البرامج الرقمية للتمكين المهني بالأكاديمية المهنية للمعلمين"></div>
</div>
<div class="col-xs-10 text-right menu-1 main-nav">
<ul>
<li>خروج</li>
</ul>
</div>
</div>
</div>
</nav>
<!-------------------------------------------------------- نموذج البحث ------------------------------------------->
<div id="gtco-subscribe">
<div class="gtco-container" dir="rtl">
<div class="row" align="center">
<div>
<p></p>
<h2 style="color:#990000">.</h2>
<h2 style="color:#FFFFFF">يمكنكم البحث بكود المعلم المرشح للترقي 2019-2020</h2>
</div>
<table align="center" style="width:300px">
<tbody><tr>
<td>
<input name="ctl00$ContentPlaceHolder1$txtSearch" type="text" id="ctl00_ContentPlaceHolder1_txtSearch" class="form-control" placeholder="ادخل كود المعلم هنا">
<span id="ctl00_ContentPlaceHolder1_RequiredFieldValidator5" style="color:Red;visibility:hidden;">*</span>
</td>
</tr>
<tr>
<td>
<input type="submit" name="ctl00$ContentPlaceHolder1$btnSearch" value="بحث" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$btnSearch", "", true, "", "", false, false))" id="ctl00_ContentPlaceHolder1_btnSearch" class="btn btn-danger btn-block" style="background-color:#FF9900;border-color:#FF9900;font-size:20pt;font-weight:bold;height:60px;width:300px;">
<br>
<span id="ctl00_ContentPlaceHolder1_RegularExpressionValidator1" style="color:White;font-weight:bold;visibility:hidden;">أدخل الكود بأرقام انجليزية</span>
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
var Page_Validators = new Array(document.getElementById("ctl00_ContentPlaceHolder1_RequiredFieldValidator5"), document.getElementById("ctl00_ContentPlaceHolder1_RegularExpressionValidator1"));
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var ctl00_ContentPlaceHolder1_RequiredFieldValidator5 = document.all ? document.all["ctl00_ContentPlaceHolder1_RequiredFieldValidator5"] : document.getElementById("ctl00_ContentPlaceHolder1_RequiredFieldValidator5");
ctl00_ContentPlaceHolder1_RequiredFieldValidator5.controltovalidate = "ctl00_ContentPlaceHolder1_txtSearch";
ctl00_ContentPlaceHolder1_RequiredFieldValidator5.errormessage = "RequiredFieldValidator";
ctl00_ContentPlaceHolder1_RequiredFieldValidator5.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
ctl00_ContentPlaceHolder1_RequiredFieldValidator5.initialvalue = "";
var ctl00_ContentPlaceHolder1_RegularExpressionValidator1 = document.all ? document.all["ctl00_ContentPlaceHolder1_RegularExpressionValidator1"] : document.getElementById("ctl00_ContentPlaceHolder1_RegularExpressionValidator1");
ctl00_ContentPlaceHolder1_RegularExpressionValidator1.controltovalidate = "ctl00_ContentPlaceHolder1_txtSearch";
ctl00_ContentPlaceHolder1_RegularExpressionValidator1.errormessage = "أدخل الكود بأرقام انجليزية";
ctl00_ContentPlaceHolder1_RegularExpressionValidator1.evaluationfunction = "RegularExpressionValidatorEvaluateIsValid";
ctl00_ContentPlaceHolder1_RegularExpressionValidator1.validationexpression = "\\d*";
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
//]]>
</script>
</form>
<!-------------------------------------------------------- End of Content ------------------------------------------->
<!-------------------------------------------------------- الفوتر ------------------------------------------->
<footer id="gtco-footer" dir="rtl" role="contentinfo">
<div class="gtco-container">
<div class="row copyright">
<div class="col-md-12">
<p class="pull-left">
<small class="block">جميع الحقوق محفوظة للأكاديمية المهنية للمعلمين - الإدارة العامة للمعلومات بالأكاديمية © 2020</small>
<small class="block">الموقع الرسمي للأكاديمية المهنية للمعلمين : www.pat.edu.eg</small>
</p>
<p class="pull-right">
</p><ul class="gtco-social-icons pull-right">
<li><img src="assets/images/suport.png" width="240" height="40" alt="إضغط هنا للتواصل مع الدعم الفني في حال واجهتك أي مشكلة"></li>
</ul>
<p></p>
</div>
</div>
</div>
</footer>
</div>
<div class="gototop js-top">
<i class="icon-arrow-up"></i>
</div>
</body></html>
This is the code till now. I am stuck at entering a ID at the search box
Const sURL As String = "http://pat.edu.eg/platform/"
Dim bot As New WebDriver, sCode As String, r As Long
With bot
'.AddArgument "--headless"
For r = 2 To 2 'Cells(Rows.Count, 1).End(xlUp).Row
sCode = Cells(r, 1).Value
.Start "Chrome", sURL
.Get "/"
.Wait 3000
.FindElementByXPath("/html/body/div[2]/button").Click
.SwitchToNextWindow
Next r
End With
I am sure the pop-up window is the focused window as I used Debug.Print .Title and the window's title is already the same ..
Majority of the elements on the webpage are JavaScript enabled element so to interact with the elements you have to induce a waiter for the desired element to be interactable and you can use either of the following Locator Strategies:
Using FindElementByCss:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
driver.Wait waitTime
driver.FindElementByCss("input.form-control[id$='ContentPlaceHolder1_txtSearch'][name*='ContentPlaceHolder1']").SendKeys "1111"
Using FindElementByXPath:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
driver.Wait waitTime
driver.FindElementByXPath("//input[#class='form-control' and contains(#id, 'ContentPlaceHolder1_txtSearch')][contains(#name, 'ContentPlaceHolder1')]").SendKeys "1111"
Reference
You can find a couple of relevant discussions in:
Trying to fill text in input box with dynamic drop down
Need help to fill number into Chrome input box with Selenium
How to send text to some HTML elements?
Instead of using ".FindElementByXPath" you might try using ".FindElementByName".
Also make sure your SeleniumWrapper library is installed in addition to the SeleniumBasic core package. Once installed, it has to be enabled in the VB window by navigating to Tools > References > SeleniumWrapper Type Library and checking that box.
Below is an example of some code that runs correctly for me and inputs text into some text box elements.
'Opens a new Chrome window and navigates to login page'
Dim obj As New WebDriver
obj.Start "chrome", ""
obj.Get "https://exampleloginpage.com"
'Pastes credentials into appropriate fields and logs in'
Dim email As String
Dim password As String
Dim keys As New SeleniumWrapper.keys 'MUST have SeleniumWrapper.exe installed locally'
email = "testemail#test.com" 'login credentials [1/2]'
password = "G3ner!cPas$word" 'login credentials [2/2]'
obj.FindElementByName("email").SendKeys (email)
obj.FindElementByName("password").SendKeys (password)
obj.SendKeys keys.Enter

Add Search Box that Loads Embed YouTube Player

I've looked and tried a BUNCH of different codes and can't figure this out.
What I'd like to do is add a search box on my page that loads a YouTube playlist based on the search query and plays it on an embedded player.
My Code:
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
function go_get(){
var base_url = 'http://www.youtube.com/embed?listType=search&list=' ;
var search_field = document.getElementById('yourtextfield').text ;
var target_url = base_url + search_field ;
var ifr = document.getElementById('youriframe') ;
ifr.src = target_url ;
return false ;
}
</script>
<form onsubmit="go_get(); return false;" >
<input type="text" id="yourtextfield"/>
<input type="submit" value="Search Playlists" />
</form>
<iframe id="youriframe" width="640" height="360" ></iframe>
</body>
</html>
Result
The search box and player loads. However, the same playlist is loaded no matter what you search.
If I right-click on the video and view the embed HTML this is the result:
<iframe width="640" height="360" src="http://www.youtube.com/embed/6DYngiqZim0?
feature=player_embedded" frameborder="0" allowfullscreen></iframe>
As you can see the src has changed. Could YouTube maybe be preventing this behavior? Perhaps my URL is wrong?
Please Help!
Just change the "text" option with "value" on line 12
<html>
<head>
<title>Youtube playlist search</title>
</head>
<body>
<script type="text/javascript">
function go_get(){
var base_url = 'http://www.youtube.com/embed?listType=search&list=';
var search_field = document.getElementById('yourtextfield').value;
var target_url = base_url + search_field;
var ifr = document.getElementById('youriframe');
ifr.src = target_url;
return false;
}
</script>
<form onsubmit="go_get(); return false;" >
<input type="text" id="yourtextfield"/>
<input type="submit" value="Search Playlists" />
</form>
<iframe id="youriframe" width="640" height="360" ></iframe>
</body>
</html>
Change:
var search_field = document.getElementById('yourtextfield').text ;
to:
var search_field = document.getElementById('yourtextfield').value ;

YUI3 find current tab in TabView

I'm using YUI3 TabView component, and I'd like to be able to get the index of the currently selected tab. I've been looking through the api docs, but can't seem to find the relevant way to do this.
http://developer.yahoo.com/yui/3/api/module_tabview.html
Thanks!
"indexOf" actually works if you use the "tabview.get('selection')" as the argument.
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript" charset="utf-8"
src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js">
</script>
</head>
<body>
<body class="yui3-skin-sam">
<p id="msg"></p>
<input type='button' value='Button' id='button'/>
<div id="demo">
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
<div>
<div id="foo">foo content</div>
<div id="bar">bar content</div>
<div id="baz">baz content</div>
</div>
</div>
<script>
var YUI;
YUI().use('event', 'node', 'tabview', function (Y) {
Y.one('#msg').set('innerHTML', 'message area');
var tabview = new Y.TabView({srcNode: '#demo'});
tabview.render();
var displayIndex = function (tabview) {
var sel = tabview.get('selection');
var idx = tabview.indexOf(sel);
Y.one('#msg').set('innerHTML', 'Selected Tab Index = ' + idx);
}
displayIndex(tabview);
Y.after('click', function(e) {
displayIndex(this);
},'body',tabview);
});
</script>
</body>
</html>

Resources