Latest recipes tagged "upload" Code RecipesLibgen Epub Upload using Tor (Python) 2015-12-06T19:23:54-08:00fuji239 <p style="color: grey"> Python recipe 579134 by <a href="/recipes/users/4193238/">fuji239</a> (<a href="/recipes/tags/beautifulsoup/">beautifulsoup</a>, <a href="/recipes/tags/libgen/">libgen</a>, <a href="/recipes/tags/mechanize/">mechanize</a>, <a href="/recipes/tags/tor/">tor</a>, <a href="/recipes/tags/upload/">upload</a>). Revision 2. </p> <p>This script shows how to upload epub files in Library Genesys (libgen) automatically by using Tor. Please note that only copyright free epubs should be used (such as those present in <a href="" rel="nofollow"></a>). It will also check if MD5 hash is present before uploading. This is provided for python educative purposes only : it shows how to use a Tor proxy, Mechanize (for uploading and form processing), Hashlib for MD5 calculation, Filemagic for mimetype detecting and BeautifulSoup for response analyzing, all together.</p> Composing a POSTable HTTP request with multipart/form-data Content-Type to simulate a form/file upload. (Python) 2014-03-08T17:34:38-08:00István Pásztor <p style="color: grey"> Python recipe 578846 by <a href="/recipes/users/4189380/">István Pásztor</a> (<a href="/recipes/tags/field/">field</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/httpclient/">httpclient</a>, <a href="/recipes/tags/mime/">mime</a>, <a href="/recipes/tags/multipart/">multipart</a>, <a href="/recipes/tags/post/">post</a>, <a href="/recipes/tags/upload/">upload</a>, <a href="/recipes/tags/web/">web</a>). Revision 5. </p> <p>This code is useful if you are using a http client and you want to simulate a request similar to that of a browser that submits a form containing several input fields (including file upload fields). I've used this with python 2.x.</p> Wrap a a file-like object in another that calls a user callback whenever read() is called on it. (Python) 2013-09-25T01:54:53-07:00Martin Miller <p style="color: grey"> Python recipe 578674 by <a href="/recipes/users/155538/">Martin Miller</a> (<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>Wraps a file-like object in another, but also calls a user callback with the number of bytes read whenever its <code>read()</code> method is called. Used for tracking upload progress, for example for a progress bar in a UI application.</p> Wrap a string in a file-like object that calls a user callback whenever read() is called on the stream (Python) 2013-09-22T21:48:03-07:00Ben Hoyt <p style="color: grey"> Python recipe 578669 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>Wraps a string in a read-only file-like object, but also calls a user callback with the number of bytes read whenever <code>read()</code> is called on the stream. Used for tracking upload progress, for example for a progress bar in a UI application.</p> Encode multipart form data for uploading files via POST (Python) 2013-09-22T21:27:24-07:00Ben Hoyt <p style="color: grey"> Python recipe 578668 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/multipart/">multipart</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>This function lets you encode form fields <em>and</em> files in multipart/form-data format for uploading files via HTTP POST.</p> Python HTTP POST binary file upload with pycurl (Python) 2008-08-14T04:47:36-07:00Robert Lujo <p style="color: grey"> Python recipe 576422 by <a href="/recipes/users/4044016/">Robert Lujo</a> (<a href="/recipes/tags/django/">django</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/post/">post</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>There is a way to upload file with standard python libraries (urllib, httplib, ...) as explained at <a href="" rel="nofollow"></a>. But that didn't worked for me for binary data. I didn't liked/tried solution explained at <a href="" rel="nofollow"></a>, so I tried with pycurl (<a href="" rel="nofollow"></a> wrapper for <a href="" rel="nofollow"></a>) because it is std. lib for php, and uploading the file is very simple (just add @&lt;path-to-file&gt; to post variable value). It was a little hard to find proper way because there is no such example or documentation. But I found it, and it is so simple ;)</p> <p>I supply django test application which receives file that is uploaded.</p>