基于 C# HttpWebRequest 和 Javascript 的表单提交操作
我正在尝试制作一个简单的网络爬虫作为学习经验,但我遇到了困难。我可以设置 cookie、获取 cookie 并在会话中保留 cookie,但是我现在在尝试提交登录信息时陷入困境。查看网站的源代码,我发现登录表单有一个用户名和密码字段,其中有一个提交按钮,其操作是 JavaScript 调用。
如果是 POST 调用,我不会有问题,但我不知道如何使用 HttpWebRequest 处理登录。是否可以?如果不是,我该如何去做呢? (我可以吗?)
I am trying to make a simple web crawler as a learning experience and I have hit a wall. I am able to set cookies, get cookies, and keep cookies over a session however I am now stuck when attempting to submit login information. Looking at the source of the website I see that the login form has a username and password field with a submit button who's action is a javascript call.
If it was a POST call I wouldn't have a problem but I can't figure out how to handle logging in using HttpWebRequest. Is it possible? If not how can I go about doing this? (Can I?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅仅因为它是 javascript 调用并不意味着您不能执行 POST。我会阅读 javascript 并查看它的作用,然后执行类似的操作。
Just because it is a javascript call doesn't mean you can't do a POST. I would read the javascript and see what it does, then do something similar.