Here is my HTML code:
html
<html>
<div class="echo-chat-body" dir="ltr">
<div class="new-chat-form">
<div>
<h1 class="echo-title desktop-only">
Topic?
</h1>
<hr class="desktop-only full-width">
<input id="topic" name="topic" autocomplete="false" placeholder="Topic?" class="js-chat-topic answer input input-text desktop-input js-chat-required-false" type="text">
</div>
<div>
<h1 class="echo-title desktop-only">
What's your name?
</h1>
<hr class="desktop-only full-width">
<input id="name" name="name" autocomplete="false" placeholder="What's your name?" class="js-chat-name answer input input-text desktop-input js-chat-required-true" type="text">
</div>
<div class="form-action">
<label></label>
<button id="startchat" class="echo-button button-secondary js-submit-new-chat center" disabled="">
Start Chat
</button>
</div>
</div>
</div>
</html>
Here is my Python code:
from urllib.parse import urlencode
from urllib.request import Request, urlopen
url = 'file:///C:/Users/SuperDesktop/HTML/Desktop/Chat.html'
post_fields = {'topic': 'Hello', 'name' : 'My Name', 'startchat': 'startchat'}
"""
Topic is 'Hello'.
Name is 'My name'.
startchat is the button which should be clicked.
" 'startchat': 'startchat' " is not the proper code to click the button.
"""
request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode()
print(json)
I tried that code but it always shows different errors.<br>
How to create a program in python that will auto-fill those 2 boxes and click on submit?
I want to fill this form via python code, I don't want to use Selenium, Automated Browser or chromedriver
I don't want python code opening a browser and filling those things and clicking start button
I also tried to use Selenium, Automated Browser, opening browser and chrome driver but that was not the thing that I wanted.
I wanted a python code that will fill those boxes and send the form within Terminator.
0 Answer(s)