Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
form fill & button clicks
#1
I've tried this in the past using requests and or selenium, as I recall requests was good a filling in the forms and selenium was okay and mimicking a browser but I haven't found a good tool to do both and I don't believe I can make them share a connection variable/object.

This is the rundown of what I need:

connect to URL

ask user to enter username and store in username-variable
ask user to enter password and store in password-variable

input data from username-variable into username field:

<input id="inptUserId" maxlength="8"
name="txt_inptUserId" onkeyup="autoSkipNN(event.which,this);" onfocus="saveFocusedControl(&quot;inptUserId&quot;);" style="background-color:Window;font-size:11px;height:19px;width:67px;line-height:11px;left:275px;padding-bottom:0;font-family:Arial;border-width:2px;position:absolute;border-style:inset;top:101px;color:000000;padding-top:0;" tabindex="26"
title="" type="text" value="">


input data from password-variable into password field:

<input id="password" maxlength="8"
name="txt_password" onkeyup="autoSkipNN(event.which,this);" onfocus="saveFocusedControl(&quot;password&quot;);" style="background-color:Window;font-size:11px;height:19px;width:67px;line-height:11px;left:445px;padding-bottom:0;font-family:Arial;border-width:2px;position:absolute;border-style:inset;top:101px;color:000000;padding-top:0;" tabindex="28"
title="" type="password" value="">


click button:

<input alt="Enter" id="btnOK"
name="btn_btnOK" onfocus="saveFocusedControl(&quot;btnOK&quot;);" style="font-family: Arial; font-size: 12px; font-weight: Bold; position: absolute; left: 19px; top: 292px; width: 49px; height: 23px; color: #ffffcc; background-color: transparent; border-width: 0px; text-align:left;padding-left:0px;padding-right: -5px;cursor: pointer; padding-left:0px;padding-right:0px;" tabindex="-1"
title="" type="submit" value="Enter">


Any suggestions on the best way to accomplish this? Thanks.
Reply
#2
Quote:I've tried this in the past using requests and or selenium, as I recall requests was good a filling in the forms and selenium was okay and mimicking a browser but I haven't found a good tool to do both and I don't believe I can make them share a connection variable/object.

I use a combination all the time. Just posted a simple example that uses Selenium to expand javascript, then beautifulsoup to parse. Although I don't do it in this simple script, there's no reason that you can't use selenium to click , fill in search boxes (and/or password info), and on target page extract links and get those pages using beautifulsoup and requests: https://python-forum.io/Thread-get-hotel...7#pid78167
Reply
#3
[quote='Larz60+' pid='78458' dateline='1556132810']
Quote:I've tried this in the past using requests and or selenium, as I recall requests was good a filling in the forms and selenium was okay and mimicking a browser but I haven't found a good tool to do both and I don't believe I can make them share a connection variable/object.

I finally got it running headless!

I'm new to Beautiful Soup, when preforming a search for buttons/text fields should I be searching via html 'id' or 'name'? Thanks.
Reply
#4
for parser, i like to use lxml
soup = BeautifulSoup(page, 'lxml')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Contact form button click action Man_from_India 1 2,752 Feb-01-2020, 06:21 PM
Last Post: snippsat
  Send email to gmail after user fill up contact form and getting django database updat Man_from_India 0 2,071 Jan-22-2020, 03:59 PM
Last Post: Man_from_India
  Radio button in form Heinrich 1 2,023 Jan-14-2020, 05:41 PM
Last Post: Heinrich
  Submit button not working when using form tuannv562 0 5,530 Apr-23-2018, 03:49 AM
Last Post: tuannv562

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020