简体   繁体   English

如何使用JavaScript输入window.prompt()的值?

[英]How to enter in values for a window.prompt() using javascript?

I am doing a small project involving web scraping basic html pages hosted on an internal server we use at work. 我正在做一个小项目,涉及Web抓取我们在工作中使用的内部服务器上托管的基本html页面。 Upon entry to these pages a popup . 进入这些页面后,将弹出一个窗口。 . . which looks exactly like a windows.prompt() asks for username and a password with a message like "Enter credentials for Proxy: ". 看起来就像windows.prompt()要求输入用户名和密码,并带有诸如“输入代理的凭据:”之类的消息。 Is there a way to automatically inject and submit these values on the prompt box using JavaScript or even python? 有没有一种方法可以使用JavaScript甚至python自动在提示框中注入并提交这些值?

Yes I do have access but every time I go to a different page it will re-prompt me and I am trying to do this for a very large amount of pages. 是的,我确实具有访问权限,但是每次我转到另一个页面时,它都会重新提示我,我正尝试在大量页面上执行此操作。

I have already tried inspecting the page but there does not seem to be any element for a popup. 我已经尝试过检查页面,但是似乎没有任何弹出元素。

I suspect you may be getting the login prompt due to the web server's setup for the page and not due to anything included in the content of the page in question. 我怀疑您可能由于该页面的Web服务器设置而不是由于相关页面内容中包含的任何内容而收到登录提示。 You may need to adjust your app's code to handle the login behavior (setting cookies in your request header for example). 您可能需要调整应用程序的代码以处理登录行为(例如,在请求标头中设置cookie)。

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

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