Basically, this is the element form, ive already identified the forms to fill however, I dont know how to use the specific button to submit:
browser['email']= "abc#gmail.com"
browser['pwd']='password'
These were identified by mechanicalsoup when browser.form.print_summary() was called.
<input autocomplete="off" class="form-control" data-lbl="Email Address" id="login_email" maxlength="255" name="email" placeholder="Enter the email address" type="email"/>
<input aria-describedby="passworderror" autocomplete="off" class="form-control" data-lbl="Password" id="login_pwd" maxlength="25" name="pwd" oncopy="return false" ondrag="return false" ondrop="return false" placeholder="Enter the password" type="password"/>
<button class="btn btn-lg button-orange" type="button">Sign In</button>
<form class="form-horizontal" id="login" role="form" method="POST">
<div class="hidden" id="mandatory-message"> is a mandatory field</div>
<div class="hidden" id="email-message">Please enter a valid email address. For example: johndoe#example.com</div>
<div class="hidden" id="password-message">Please enter 6 or more characters. Leading or trailing spaces will be ignored.</div>
<div class="form-group col-md-12 ">
<label class="control-label " for="login_email">Email Address*</label>
<input type="email" class="form-control valid" id="login_email" name="email" data-lbl="Email Address" placeholder="Enter the email address" autocomplete="off" maxlength="255">
<span id="loginEmailError" class="error"></span>
</div>
<div class="form-group col-md-12">
<label class="control-label" for="login_pwd">Password*</label>
<i id="eye-icon" class="fa fa-fw fa-eye field-icon"></i>
<input type="password" class="form-control valid" id="login_pwd" name="pwd" data-lbl="Password" placeholder="Enter the password" autocomplete="off" maxlength="25" oncopy="return false" ondrag="return false" ondrop="return false" aria-describedby="passworderror">
<span id="passworderror" class="error"></span>
</div>
<div class="form-group col-md-12">
<div class="reloadModal">Forgot your password?</div>
</div>
<div class="login-loading">
<p></p>
<div class="line-pulse"><div></div><div></div><div></div><div></div></div>
</div>
<div class="form-group col-md-12 text-center" id="login_submit">
<button type="button" class="btn btn-lg button-orange">Sign In</button>
</div>
</form>```
Related
So, I have multiple jobs in view with "Report" modal. in that modal there is a form with reasons to report. The problem is that radio button highlights only in first form. if I open report for fifth job it will change first job report modal and there will be no button highlight, but if you open modal of first job, its highlight. I made sure to change name= attribute of every group, so I don't understand why it's happening
<!-- Modal report posting -->
<div class="modal" id="{{post.id}}-1" tabindex="-1" role="dialog" aria-labelledby="validate-modal-label" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Report</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{{post.id}}
<div class="modal-body">
<form action="" class="report_job_form" method="post" novalidate>
<input type="hidden" name="crf-protect" id="crf-protect" value="{{csrf_token()}}">
<div class="report-element">
<div class="report-category hoverable">
<p>
<label for="fkj">
<input type="radio" id="fkj" name="report{{post.Position}}_value" value="Fake Job">
<span>Fake Job</span>
</label>
</p>
</div>
<div class="report-category hoverable">
<p>
<label for="disc-3">
<input type="radio" id="disc-3" name="report{{post.Position}}_value" value="Discrimination">
<span>Discrimination</span>
</label>
</p>
</div>
<div class="report-category hoverable">
<p>
<label for="advert">
<input type="radio" id="advert" name="report{{post.Position}}_value" value="Advertisement">
<span>Advertisement</span>
</label>
</p>
</div>
<div class="report-category hoverable">
<p>
<label for="other-2">
<input type="radio" id="other-2" name="report{{post.Position}}_value" value="Other">
<span>Other</span>
</label>
</p>
</div>
</div>
<div class="input-field col s12">
<textarea id="textarea7" class="materialize-textarea" data-length="120" name="details"></textarea>
<label for="textarea2">More Details</label>
</div>
<input type="hidden" name="user-ident" id="user-ident" value="{{current_user.id}}" readonly>
<input type="hidden" name="post-ident" id="post-ident" value="{{post.id}}" readonly>
<input class="btn report-submit" type="submit">
</form>
</div>
All I want to do is to have a condition in order when the user clicks FOR SALE button to be redirected to url 'salesearch' or when clicks TO RENT to be redirected to url 'rentsearch'.
Here's the code:
<div class="search">
<form action="{% url 'salesearch' %}">
<div class="form-row">
<div class="col-md-4 mb-3">
<label class="sr-only">
Keywords
</label>
<input class="form-control" name="keywords" placeholder="Keyword (Pool, Garage, etc)" type="text">
</div>
<div class="col-md-4 mb-3">
<label class="sr-only">
City
</label>
<input class="form-control" name="city" placeholder="City" type="text">
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<button class="btn btn-secondary btn-block mt-4" name="For Sale" type="submit">
For Sale
</button>
</div>
<div class="col-md-6 mb-3">
<button class="btn btn-secondary btn-block mt-4" name="To Rent" type="submit">
To Rent
</button>
</div>
</div>
</div>
</form>
</div>
With the above example I am redirected always at url 'salesearch path. Is there any way to have a conditional to determine the url's path?
Sure is!
You can set formaction on button elements:
<button name="For Sale" type="submit" formaction="{% url 'salesearch' %}">
For Sale
</button>
<button name="To Rent" type="submit" formaction="{% url 'rentsearch' %}">
To Rent
</button>
I have created a form in Flask, and want to submit certain values which need to be processed.But the method used is getting defaulted to GET even though I have specified the method as post in my form
These are the the relevant code files:
app.py
#app.route('/test',methods=["GET","POST"])
def test():
print(request.method)
error = None
try:
if request.method == "POST":
first_name = request.form['firstname']
last_name = request.form['lastname']
flash(first_name)
flash(last_name)
return render_template("test.html")
else:
return "Wrong"
except Exception as e:
return str(e)
test.html
<form method="post" class="text-center" style="color: #757575;" action="">
<div class="form-row">
<div class="col">
<!-- First name -->
<div class="md-form">
<input type="text" name="firstname" value="{{request.form.firstname}}" class="form-control">
<label for="materialRegisterFormFirstName">First name</label>
</div>
</div>
<div class="col">
<!-- Last name -->
<div class="md-form">
<input type="text" name="lastname" value="{{request.form.lastname}}" class="form-control">
<label for="materialRegisterFormLastName">Last name</label>
</div>
</div>
</div>
<!-- File Upload -->
<div class="md-form">
<input type="file" id="fileupload" class="form-control">
</div>
<input class="btn btn-info btn-block" type="submit" value="Submit">
</form>
The method is getting defaulted to post and the response "Wrong" on loading 127.0.0.1:5000/test. The method is always GET
<form method="post" class="text-center" style="color: #757575;" action="/test" method="post">
<div class="form-row">
<div class="col">
<!-- First name -->
<div class="md-form">
<input type="text" name="firstname" value="{{request.form.firstname}}" class="form-control">
<label for="materialRegisterFormFirstName">First name</label>
</div>
</div>
<div class="col">
<!-- Last name -->
<div class="md-form">
<input type="text" name="lastname" value="{{request.form.lastname}}" class="form-control">
<label for="materialRegisterFormLastName">Last name</label>
</div>
</div>
</div>
<!-- File Upload -->
<div class="md-form">
<input type="file" id="fileupload" class="form-control">
</div>
<input class="btn btn-info btn-block" type="submit" value="Submit">
</form>
By adding the "route" to the action attribute and defining the method of submission of form, you can perform the desired objective.
Can't figure out why Google won't let me log into my account. I put my email inside a variable called my_mail then search for it in the html but the results came back false.
I am using the requests & beautifulsoup modules to do so.
What I have:
from bs4 import BeautifulSoup
import requests
form_data={'Email': 'ExampleEmail#gmail.com', 'Passwd': 'Password'}
post = "https://accounts.google.com/signin/challenge/sl/password"
my_mail = 'ExampleEmail#gmail.com'
with requests.Session() as s:
soup = BeautifulSoup(s.get("https://accounts.google.com/ServiceLogin?elo=1").text, "html.parser")
for inp in soup.select("#gaia_loginform input[name]"):
if inp["name"] not in form_data:
form_data[inp["name"]] = inp["value"]
s.post(post, form_data)
print(my_mail in "https://mail.google.com/mail/u/0/#inbox")
Form info:
<form novalidate="" method="post" action="https://accounts.google.com/signin/challenge/sl/password" id="gaia_loginform">
<input name="Page" type="hidden" value="PasswordSeparationSignIn">
<input type="hidden" name="GALX" value="c90FYb-yd6E">
<input type="hidden" name="gxf" value="AFoagUVMILWKQvqlGV0i8sJG83jiQlrWzg:1475424777331">
<input id="profile-information" name="ProfileInformation" type="hidden" value="">
<input type="hidden" id="_utf8" name="_utf8" value="☃">
<input type="hidden" name="bgresponse" id="bgresponse" value="js_disabled">
<input type="hidden" id="pstMsg" name="pstMsg" value="1">
<input type="hidden" id="dnConn" name="dnConn" value="">
<input type="hidden" id="checkConnection" name="checkConnection" value="youtube:230:1">
<input type="hidden" id="checkedDomains" name="checkedDomains" value="youtube">
<div class="form-panel first valid" id="gaia_firstform">
<div class="slide-out ">
<div class="input-wrapper focused">
<div id="identifier-shown">
<div>
<label class="hidden-label" for="Email">
Enter your email</label>
<input id="Email" type="email" value="" spellcheck="false" name="Email" placeholder="Enter your email" autofocus="">
<input id="Passwd-hidden" type="password" spellcheck="false" class="hidden">
</div>
</div>
<span role="alert" class="error-msg" id="errormsg_0_Email"></span>
</div>
<div style="display: none" id="identifier-captcha">
<input type="hidden" name="identifiertoken" id="identifier-token" value="">
<input type="hidden" name="identifiertoken_audio" id="identifier-token-audio">
<div class="audio-box">
<div id="playIdentifierAudio"></div>
</div>
<div id="captcha-box" class="captcha-box">
<div id="captcha-img" class="captcha-img" data-alt-text="Visual verification">
</div>
<span class="captcha-msg">
Letters are not case-sensitive
</span>
</div>
<label for="identifier-captcha-input" class="hidden-label"></label>
<input type="text" id="identifier-captcha-input" name="identifier-captcha-input" class="captcha" placeholder="Enter the letters above" title="Type the characters you see or numbers you hear">
</div>
<input id="next" name="signIn" class="rc-button rc-button-submit" type="submit" value="Next">
<a class="need-help" href="https://accounts.google.com/signin/usernamerecovery?hl=en">
Find my account
</a>
</div>
</div>
<a href="https://accounts.google.com/ServiceLogin" tabindex="-1">
<img id="back-arrow" class="back-arrow " aria-label="Back" tabindex="0" alt="Back" src="https://www.gstatic.com/images/icons/material/system/1x/arrow_back_grey600_24dp.png">
</a>
<div class="form-panel second">
<div class="slide-in hide-form">
<div>
<p id="profile-name"></p>
<span id="email-display"></span>
</div>
<div>
<div id="password-shown"></div>
</div>
<input id="signIn" name="signIn" class="rc-button rc-button-submit" type="submit" value="Sign in">
<label class="remember">
<input id="PersistentCookie" name="PersistentCookie" type="checkbox" value="yes" checked="checked">
<span>
Stay signed in
</span>
<div class="bubble-wrap" role="tooltip">
<div class="bubble-pointer"></div>
<div class="bubble">
For your convenience, keep this checked. On shared devices, additional precautions are recommended.
Learn more
</div>
</div>
</label>
<input type="hidden" name="rmShown" value="1">
<a id="link-forgot-passwd" class="need-help" href="https://accounts.google.com/signin/recovery?hl=en">
Forgot password?
</a>
</div>
</div>
<span id="inge" style="display: none" role="alert" class="error-msg">
Sorry, Google doesn't recognize that email. Create an account using that address?
</span>
<span id="timeoutError" style="display: none" role="alert" class="error-msg">
Something went wrong. Check your connection and try again.
</span>
</form>
I don't plan on using Google's API. I don't want to be restricted.
Why is the login failing? What could I do to fix it?
I need to login to scrap some information that requires a login.
Pyhton 3.4.2
I want to submit a form in Python requests. I'm trying to get the list of all members of my organisation from the website.
I've tried the following code:
searchparams={'name':'smith', 'grade':'0', 'format':'html'}
r=requests.post('http://www.thewebsite.co.uk/members/dir/search', data=searchparams)
but it just returns the HTML of the search screen, not the results.
There are also a bunch of other options I could select, but these are the only ones I care about - do I need to submit values for them all?
The form HTML is below, for you information.
<form method="post" action="/members/dir/search" class="col-md-8">
<div class="form-group">
<label for="phone">Surname:</label>
<input type="text" name="name" value="" class="form-control" />
<div class="note">Leave blank to search for all surnames</div>
</div>
<div class="form-group">
<label for="grade">Grade:</label>
<select name="grade" class="form-control">
<option value="0">ALL</option>
<option value="G6">Grade 6</option>
<option value="G7">Grade 7</option>
</select>
</div>
<label>Results format:</label>
<div class="radio">
<label for="format">HTML</label> <input class="tick" type="radio" name="format" value="html" checked="checked" />
</div>
<div class="radio">
<label for="format">Excel</label> <input class="tick" type="radio" name="format" value="excel" />
</div>
<div class="radio">
<label for="format">CSV</label> <input class="tick" type="radio" name="format" value="csv" />
</div>
<div class="form-group">
<button type="submit" name="" class="btn btn-danger">Search</button>
</div>
</form>