gpt4 book ai didi

asp.net - 从登录后的页面获取 HTML

转载 作者:行者123 更新时间:2023-11-28 05:10:10 26 4
gpt4 key购买 nike

这个问题是我的 previous question 的后续问题关于从 ASPX 页面获取 HTML。我决定尝试使用 webclient 对象,但问题是我得到了登录页面的 HTML,因为需要登录。我尝试使用 webclient 对象“登录”:

WebClient ww = new WebClient();

ww.DownloadString("Login.aspx?UserName=&Password=");

string html = ww.DownloadString("Internal.aspx");

但我仍然一直得到登录页面。我知道用户名信息没有存储在 cookie 中。我一定是做错了什么或者遗漏了一个重要的部分。有谁知道它可能是什么?

最佳答案

尝试设置 WebClient 对象的凭证属性

WebClient ww = new WebClient();
ww.Credentials = CredentialCache.DefaultCredentials;
ww.DownloadString("Login.aspx?UserName=&Password=");
string html = ww.DownloadString("Internal.aspx");

关于asp.net - 从登录后的页面获取 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com