简体   繁体   English

如何发出python请求,加载javascript,填写表格并点击提交

[英]How to make a python request, load javascript, fill in the form and click submit

So there is a page with the following contents; 因此,页面包含以下内容;

<input type="text" name="input1">
<input type="text" name="input2">
<button onclick="dosomething()" id="check">Check</button>

This page gets loaded in with javascript, so you need to wait until it's fully loaded. 该页面已使用javascript加载,因此您需要等待直到完全加载为止。 After that the text files has to be filled in, and click the submit button. 之后,必须填写文本文件,然后单击提交按钮。 If it succeeds, it will set a cookie and redirect you. 如果成功,它将设置一个cookie并重定向您。 If it doesn't succeeds, it doesn't do anything. 如果没有成功,那么它什么也不会做。

How can I make this work in python? 如何在python中进行这项工作? I couldn't really find a answer that would work for me. 我找不到真正适合我的答案。 This python code will be runned in Windows. 此python代码将在Windows中运行。

Most likely you could just send direct request with form's field. 您最有可能只发送带有表单字段的直接请求。 Based on form's method it'll be GET or POST request. 根据表单的方法,它将是GET或POST请求。 Later you can catch and save coockies and head to redirected page. 稍后,您可以捕获并保存Coockies,然后转到重定向的页面。 If it doesn't work you could also try Selenium to emulate user's behaviour 如果它不起作用,您还可以尝试使用Selenium模拟用户的行为

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM