python requests (form filling)
11,026
You need to login and post to the save url, you also need to pass the note number in the form data:
import requests
save = "https://anotepad.com/note/save"
txt = "Hello World"
login = "https://anotepad.com/create_account"
data = {"action": "login",
"email": "[email protected]",
"password": "xxxxxx",
"submit": ""}
# construct the POST request
with requests.session() as s: # Use a Session object.
s.post(login, data) # Login.
form_data = {"number": "2yrwpi",
"notetype": "PlainText",
"noteaccess": "2",
"notequickedit": "false",
"notetitle": "whatever",
"notecontent": txt}
r = s.post(save, data=form_data) # Save note.
r.json()
will give you {"message":"Saved"}
on success. Also if you want to see what notes you have, after logging in, run s.post("https://anotepad.com/note/list").text
.
Author by
Nimish Bansal
Updated on June 27, 2022Comments
-
Nimish Bansal almost 2 years
This is the link to a page filling forms...
https://anotepad.com/notes/2yrwpi
where I have to enter the content in the text area (say)("hello world") and then press save, but all this is to be done with python
request
module (get, post etc) and without the use of selenium and beautifulsoup module.I tried something like:
url="https://anotepad.com/notes/2yrwpi" txt = "Hello World" #construct the POST request form_data = {'btnSaveNote':'Save', 'notecontent' : txt} post = requests.post(url,data=form_data)
But that doesn't seem to be working
Please help!