以编程方式将文件上传到网站并捕获输出(如何查找网站的上传链接) [英] Programmatically upload file to website and capture output (how to find upload link for the website)

查看:88
本文介绍了以编程方式将文件上传到网站并捕获输出(如何查找网站的上传链接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个WPF应用程序,它将文件上传到网站并捕获输出以显示在应用程序窗口中。但我无法找到一个很好的方法来找到网站上传按钮后面的链接上传文件。

例如,我不能只上传到xyz.com,而是我需要网站上传按钮后面的链接,它会告诉文件上传的位置,可能就像xyz.com \ upload。

我不知道是否有更好的方法可以不需要链接。



我找到 SVG to Vector Drawable Converter - 在线将SVG图像转换为Android VectorDrawable XML资源文件 [ ^ ]右键单击>检查然后查看后面的代码,我找到的链接在下面的代码中。



我需要 Android SVG到VectorDrawable [ ^ ]或更好的方式来完成任务而不需要该链接。



我尝试过:



I am making a WPF app that would upload file to a site and capture output to display on the app window. But i am not able to figure out a good way to find link behind the upload button of the site to upload the file to.
For example, i cannot just upload to xyz.com rather i need the link behind the upload button of the site that would tell where the file is uploaded which could be like xyz.com\upload.
I don't know if there a better way to do it without requiring the link.

I found the upload link for SVG to Vector Drawable Converter – Convert SVG images to Android VectorDrawable XML resource files online[^] by Right click > Inspect and then looking at the code behind, the link i found is in the code below.

I need the link for Android SVG to VectorDrawable[^] or a better way to accomplish the task without needing that link.

What I have tried:

String uriString = "http://193.124.64.166/api/svg2vd/v1";

// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

//Filepath contains the path of the .svg file on my local machine
string fileName = FilePath;

// Upload the file to the URI.
var responseArray = myWebClient.UploadFile(uriString, "POST", fileName);

// Decode and display the response.
// ProcessData is my method that formats the data returned by the WebClient
string[] results =     VectorDataProcess.ProcessData(System.Text.Encoding.ASCII.GetString(responseArray));

推荐答案

页面抓取是一种与网站合作的不受欢迎的方法。如果你必须以这种方式做到这一点,在很小的容量,它可能会被忽视。



要查看任何HTTP流量发生了什么,并确定发生了什么,你需要一个HTTP嗅探器,如: Fiddler - 免费的网络调试代理 [ ^ ]



安装和配置后,使用像你这样的网站通常会手动并进行上传。现在点击左侧的数据包,查看右侧的请求,您将看到确切的内容。
Page scraping is a frowned up method of working with websites. If you must do it this way, in a small capacity, it may go unnoticed.

To see what is happening with any HTTP traffic, and identify what is happening, you need a HTTP sniffer like: Fiddler - free web debugging proxy[^]

Once you have it installed and configured, use the website like you usually would manually and do the upload. Now click on the packet on the left, and look at the request on the right and you will see exactly what is required.


这篇关于以编程方式将文件上传到网站并捕获输出(如何查找网站的上传链接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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