Question

I need to upload hundreds of files via a html form, so that they end up on a server. I have no other options and must go via the form.

I have tried doing this problematically using python but I'm doing something wrong and the files are empty when I try to open them via the web interface. I also tried doing a replay via firefox's TamperData and the file is also uploaded incorrectly in this case.

So I'm interested in exploring the idea of uploading the files by automating my browser instead. All I need to do is:

for file in files:
   open a page 
   click on the browse button 
   select a file
   click the upload button

So what software/library can I use to do this? I don't necessarily need to do this using python as I will never need to do this again in the future. I just need to get the files up there by any means possible.

I have access to Windows 7, Mac Os X, and Suse Linux.

I also don't care which browser I use.

Was it helpful?

Solution

Splinter works well for this kind of thing:

https://github.com/cobrateam/splinter

You could do something like:

from splinter import Browser

with Browser('firefox') as browser:
    browser.visit('http://yourwebsite.com')
    browser.find_by_name('element_name').click()
    do some other stuff...

You just need to find the name or ID of the element you want to interact with on the page

OTHER TIPS

please check out selenium: It's an automated browser tool (behaves like a real user)

http://selenium-python.readthedocs.org/en/latest/

You can also if you're more the techy type and understand html write your own python code to only send files to the server with httplib2

https://code.google.com/p/httplib2/

for an auto clicker try autopy (this emulates mouse and keyboard input)

http://www.autopy.org/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top