I am trying to use Scrapy to pull more information from another page. I was able to login with my last project and am modeling this one after it. The login page for this particular site is much different, however. Here is the markup for the page with the relevant information provided:
<div id="form" style="display:inline;">
<form id="login" class="gfimaxrmform2" name="gfimaxform" action="" method="post" onsubmit="return attemptLogin(this);" >
<label for="username">User name:</label>
<input alt="blank" size="30" id="username" name="username" type="text" />
<br />
<label for="password">Password:</label>
<input alt="blank" size="30" id="password" name="password" type="password" />
<br />
<br />
<script type="text/javascript">document.write("<input name='url' id = 'url' type='hidden' value = '"+document.URL+"'>")</script>
<div class="formfields_belowfields">
<button class="submit" type="submit">Login</button>
</div>
</form>
</div>
I am trying to use my code to login and then go to another website but I am not sure how to make it "click" submit. Here is the code I am working on:
def parse(self, response):
return[FormRequest.from_response(response, formdata = {"username" : user, "password": password}, callback = self.after_login)]
The `after_login' will just make sure that I am logged in, however it doesn't seem to be clicking the submit button to go to the next page.
edit: The link to the page I am trying to log in to is: Here
I ended up using Selenium to really simplify this process. If anyone discovers a need for something in the future I would recommend using it.
Related
I got my website over on the Github Pages Service. I'm trying to implement the FormSpree free contact form but after you submit the form, it redirects you to a different website. Something I'd like to avoid. So I looked it up on the internet and of course others wanted to get rid of it too (I omitted my email in the below picture).
This is the form I got above but it doesn't actually work at all. It worked before I tried to fiddle with it though.
Here is what the form looks like by default from FormSpree:
<form action="//formspree.io/your#email.com"
method="POST">
<input type="text" name="name">
<input type="email" name="_replyto">
<input type="submit" value="Send">
</form>
Here is my version (which worked fine before I tried to get around the redirect)
<div class=modal-body style="background-color: #454545">
<p>Please use the form below to contact us regarding feedback or any questions you may have!
We will never use the information given below to spam you and we will never pass on your
information to a 3rd party.</p>
<p>As we are using <a target="_blank" href="http://formspree.io">FormSpree</a> for this form
please consult their privacy policy for any questions regarding this matter.</p>
<form id="contactform" method="POST">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Name</span>
<input name="form-name-input" type="text" name="name" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Email</span>
<input name="form-email-input" type="email" name="_replyto" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Subject</span>
<input name="form-subject-input" type="text" name="subject" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Description</span>
<textarea name="form-description-input" name="description" class="form-control" rows="4" cols="60" required></textarea>
</div>
<input type="text" name="_gotcha" style="display:none" />
<input class="btn btn-success" data-dismiss="modal" type="submit" id="form-submit-btn" value="Submit">
<input type="hidden" name="_next" value="http://www.dynamicrealities.net" onclick="FormSentConfirmation()"/>
</div>
<script>
var contactform = document.getElementById('contactform');
contactform.setAttribute('action', '//formspree.io/' + 'dynamicrealities#gmail.com');
</script>
</form>
</div>
<div class="modal-footer" style="background-color: #333333">
<button class="btn btn-danger btn-bg" data-dismiss="modal" type="button" id="form-dismiss-btn" onclick="">Close</button>
</div>
And when I call _next I want it to execute the following alert:
function FormSentConfirmation() {
alert('Thanks for the email, we\'ll be in touch promptly.');
}
When I press the Submit button, all that happens is that the form goes away but I don't receive any emails. I'm probably just doing this wrong as I am fairly new still to HTML/JavaScript.
Update: The feature available only on paid plans.
Use this hidden input field inside the form for redirection after form submission. You can redirect users to a page that you like or you have created by using this code block.
<input type="hidden" name="_next" value="//site.io/thanks.html" />
replace value with a valid thank-you page URL.
Follow this link for a tutorial on how to use Formspree and also a video demo
Follow their AJAX example at the bottom: https://formspree.io/
$("#sendMessage").on("click", function() {
$.ajax({
url: "//formspree.io/dynamicrealities#gmail.com",
method: "POST",
data: {message: "hello!"},
dataType: "json"
});
});
Remember to include jQuery as well for this to work. Remove the:
var contactform = document.getElementById('contactform');
contactform.setAttribute('action', '//formspree.io/' + 'dynamicrealities#gmail.com
and replace it with my code and change the selector. Or use $("form").on("submit"...
Here is my example, which sends you a mail and prompts an alert for the user: http://jsfiddle.net/228d4snb/
Do anything you'd like to do right before that return false;
You can put the form in an iframe so only the iframe gets redirected. What I did was create a separate html doc with just the contact form html (and any associated scripts) and then in my actual contact.html page I put:
<iframe src="contact-form.html" class="container"></iframe>.
Style the iframe to the appropriate size and with no border and it should work swimmingly.
Short Process description: The User put all required information into our website ( php / mysql / js enabled). With pushing "Enter" all information should be spread/shared to all relevant counter parts.
My Idea
Therefore I'd like to pass the information "Username, Email. Realname" to a "foreign" Mantis website (manage_user_create_page.php) where I do not have the possibility to change the code. The Target looks like:
<div align="center">
<table class="width50"><tr>
<form method="post" action="manage_user_create.php">
...
...
<input type="text" name="username" size="32" maxlength="32" />
...
<input type="text" name="realname" size="32" maxlength="64" />
...
<input type="text" name="email" size="32" maxlength="64" />
...
<input type="submit" class="button" value="Create User" />
...
...
</tr></table></form></div>
I already tried to open it like: http://..../manage_user_create.php?username=Whatever
Is there any solution to put this Information, from my site into their one (more or less automatically) and maybe Submit() it, too? getElementById() wouldn't work, because of missing "id"...
Any suggestions?
I have Internet service. They provide Login page for internet Login (Ex: i.e. http://globalNetSolutions.com/Login.html). If i am buying one website (Ex : i.e. http://MyNetSolutions.com/Login.html) is it possible to From my website username & password to http://globalNetSolutions.com/Login.html website (because of that 3rd party site not looking grate.i want login from my own website.)
I changes are needed where do i change my code :
<form action="" method="post" onSubmit="">
<h2>LOGIN TO <span class="red"><strong>MyNetSolutions</strong></span></h2>
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="choose a username...">
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="choose a password...">
<button type="submit">LOGIN</button>
</form>
You can use oauth for lo-gin purpose. But problem with that is you can not use user password for encryption. Id you do not care about that, then you can go ahead with oauth approach.
I'm working on a web site that runs in a single document (no real page loads after the first, its all ajax) that you must log in to view. The front page's log in form autofills exactly as you would expect.
The problem is when I load the login form in an iframe. On most browsers it autofills with the same info as the front page and works perfectly. But in the android browser it does not autofill the form at all.
I guess my question is, is there a way to make it function properly in the android browser without just autofilling it server side in the html?
Heres the form's html:
<form method="POST" id="login_form" class="disable_on_submit">
<input type="hidden" name="action" value="login" />
<div class="row first">
<label for="username">Email Address:</label>
<input type="email" name="username" id="username" placeholder="Email Address..." />
</div>
<div class="row">
<label for="password">Password:</label>
<input type="password" name="password" id="password" placeholder="Password..." />
</div>
<input type="submit" name="submit" id="submit" class="awesome" value="Login" />
</form>
So, I couldn't find a direct fix to this issue, I however did come up with a bit of a hack.
First you add a copy of your login form to your actual document, not the iframe:
this.fake_form = $('<form method="POST" id="login_form" autocomplete="on"><input type="email" name="username" id="username" /><input type="password" name="password" id="password" /></form>');
$(document.body).append(this.fake_form);
this.fake_form.hide();
Then you poll your fake form for auto filled data. Being that its hidden, you know the user didn't enter anything.
function check_fake_form()
{
var real_form = this.iframe.contents().find('body #whiteboard');
var real_u = real_form.find('#username');
var real_p = real_form.find('#password');
//if the real form has any values, we're done
if (real_u.val().trim() != '' || real_p.val().trim()) {
return;
}
var fake_u = this.fake_form.find('#username').val().trim();
var fake_p = this.fake_form.find('#password').val().trim();
//if the fake form has values, put them in the real form and quit
if (fake_u != '' || fake_p != '') {
real_u.val(fake_u);
real_p.val(fake_p);
return;
}
//check again in a short time
setTimeout(check_fake_form, 50);
}
This appears to work flawlessly in the version of android that wasn't working, and it does not interfere with browsers that work on their own.
We have an internal application that requires the same username/password across the board.
However, if the login fails too many times, then the account is locked for that username.
We can't change the lockout because that will affect the public facing site as well.
I have been asked to come up with a way to essentially, click a button and auto-login.
Initial research has brought me to this script... (Credit)
<!doctype html>
<!-- saved from url=(0014)about:internet -->
<html>
<title>Auto Login</title>
</head>
<body>
<form id="loginForm" name="loginForm" method="post" action="http://mail.google.com">
<select name="uni_url" id="logServer" class="validate[required]">
<option class="" value="" fbUrl="" cookieName="" >
Test_en
</option>
</select>
<input id="loginName" name="name" type="text" value="Username" class="" />
<input id="loginPassword" name="password" type="password" value="ExamplePassword" class="" />
<input type="hidden" id="loginKid" name="kid" value=""/>
</form>
<script>document.loginForm.submit();</script>
</body></html>
...but I can't seem to get it to work for me.
So, I found another option where I can create a small html file (form) with a submit button, that does - onload="form1.submit();", and this could basically log me into this website without having to key in any login information.
Not sure where to start with mimicking a login form like this and need a good direction to get started in.
Thoughts?
Let's assume your existing login form looks like this:
<form action="/login.php" method="post" id="loginform">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" />
</form>
On your "auto-login" (which is really an auto-submit) page you want to mimic the same structure as before but:
Add in values to be submitted (static username and password?)
Optionally remove the submit button (if you know your users have JS enabled then you can get rid).
Add some JS that automagically submits the form for you.
That might give us something like this:
<form action="/login.php" method="post" id="loginform">
<input type="text" name="username" value="gvee" />
<input type="password" name="password" value="hunter2" />
</form>
<script type="text/javascript">document.forms[0].submit()</script>
The javascript will essentially look for the first form on the page (forms[0]) and submit that.
Update
Upon further inspection your existing login form is a bit of a funny onion. Instead of submitting the form directly, it's calling a function called doLogin() that sets certain hidden properties.
Therefore, instead of submitting the form, we should mimic the same behaviour (i.e. call doLogin() instead of .submit()).
One key thing here is that you'll want to only call the function after it has been declared. Simplest solution is to put our added bit of script at the very bottom of the HTML.
<script type="text/javascript">doSubmit();</script>