这是填写表格页面的链接...
https://anotepad.com/notes/2yrwpi
我必须在文本区域中输入内容(例如)(“hello world”),然后按保存,但这一切都是用 python 完成的request而不使用 selenium 和 beautifulsoup 模块。
我尝试过类似的东西:
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)
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用
请帮忙!
您需要登录并发布到保存网址,还需要在表单数据中传递注释编号:
import requests
save = "https://anotepad.com/note/save"
txt = "Hello World"
login = "https://anotepad.com/create_account"
data = {"action": "login",
"email": "you@whatever.com",
"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.
Run Code Online (Sandbox Code Playgroud)
r.json()会给你带来{"message":"Saved"}成功。另外,如果您想查看您有哪些笔记,请在登录后运行s.post("https://anotepad.com/note/list").text。
| 归档时间: |
|
| 查看次数: |
15350 次 |
| 最近记录: |