使用HTTP POST将文件上载到网站 [英] Using HTTP POST to upload a file to a website

查看:425
本文介绍了使用HTTP POST将文件上载到网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会说,我从来没有真正处理过HTTP POST和只使用GET很淡然开始。

I'll start by saying that I've never really dealt with HTTP POST before and have only used GET very lightly.

我的问题是,有一个文件上传按钮的网站(这是上传你的简历,所以需要.txt文件等等)。该网站还需要一个用户名和密码(以防万一你需要的)。

My problem is, there is a website with a file upload button (it is to upload your resume, so it takes .txt files and such). The website also requires an user name and password (just in case you need that).

我使用硒(Java)来(据我所知)过程自动化,但是硒并没有这样的事。我试着只是让另一个脚本(AutoIt的),将字面上点击,当您点击上传文件按钮,在弹出的上传窗口上。不过,我需要这个脚本在Unix和Win工作。

I'm using selenium (Java) to automate the process, however selenium (as far as I know) doesn't have anything like this. I tried just making another script (in AutoIt) that will literally click on the upload window that pops up when you click on the upload-file button. However, I need this script to work on both Unix and Win.

环顾四周后,我已经学会了HTTP POST可以上传文件,但我找不到在哪里我不希望已经知道HTTPConnections一个LOT任何教程。我知道,Java有一个HTTPConnections类,这样做,但我不能弄明白。

After looking around, I've learned that HTTP POST can upload files, however I can't find any tutorials where I'm not expected to already know A LOT about HTTPConnections. I know that Java has an HTTPConnections class that does it, but I can't figure it out.

有人可以张贴小,易于遵循的例子如何使用HttpURLConnection的类java吗?

Can someone post a small, easy to follow example of how to use the HttpURLConnection class in java?

在此先感谢。

推荐答案

首先,AutoIt的效果很好Linux下的葡萄酒。我用了几次。
对于上传问题,给一个尝试的Apache的HttpClient 具有一整套的范例,包括POST那些

First, AutoIt works well under Linux with Wine. i've used it a few times. As for the upload problem, give a try to Apache HttpClient which has a whole set of examples, including POST ones

有一些工作得到acustomed的API,但肯定不会浪费时间为HttpClient的是一个伟大的图书馆

There are some work to get acustomed to the API, but that will definitely not be a waste of time as HttpClient is a great library

这篇关于使用HTTP POST将文件上载到网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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