使用Windows应用程序登录网站并从网站下载附件 [英] Login to website using windows application and download attachment from the website

查看:71
本文介绍了使用Windows应用程序登录网站并从网站下载附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我从Windows应用程序登录网站时遇到问题。在网站登录后需要下载网站订单的附件。



我尝试了什么:



我试图浏览链接但无法将用户名和密码传递到网站登录网站并阅读网站代码。

解决方案

在你的这个问题中,一个更简单的方法是,如果可以找到一些可以让你这样做的API或库。



但是既然你不打算使用,或者服务不公开API,唯一的方法就是使用一个外部库来支持你解析并验证您获得的HTML响应。例如, HtmlAgilityPack [ ^ ]是我过去常常在自己的应用程序中使用的库之一。使用此库来处理HTML页面,发送新请求,获取页面响应。



HttpClient类(System.Net.Http)| Microsoft Docs [ ^ ]



一个问题是,您的HTTP客户端可能无法发送HTTP cookie,请参阅此链接,了解如何通过真实浏览器共享您的Cookie,如何在HTTP协议中传递cookie? - 堆栈溢出 [ ^ ]

Hi,

I have a problem to login website from windows application. After login in website need to download attachment of the website orders.

What I have tried:

I have tried to browse the link but unable to pass username and password to the website to login on website and read website code.

解决方案

In this problem of yours, a very easier way would be if there can be found some of their APIs or libraries that can let you do this.

But since you do not intend to use, or perhaps the service does not expose an API, the only way to do this is using an external library that will allow you to parse and validate the HTML response that you get back. For example, HtmlAgilityPack[^] is one of such libraries that I used to consume in my own apps back in the days. Use this library to work around with the HTML pages, and send new requests, get responses for the pages.

HttpClient Class (System.Net.Http) | Microsoft Docs[^]

One problem with this is, that your HTTP clients might not be able to send the HTTP cookies, please see this link to find out how your cookies would be shared by a real browser, How are cookies passed in the HTTP protocol? - Stack Overflow[^]


这篇关于使用Windows应用程序登录网站并从网站下载附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆