How to upload file with python requests?

I’m performing a simple task of uploading a file using Python requests library. I searched Stack Overflow and no one seemed to have the same problem, namely, that the file is not received by the server: import requests url=”http://nesssi.cacr.caltech.edu/cgi-bin/getmulticonedb_release2.cgi/post” files={‘files’: open(‘file.txt’,’rb’)} values={‘upload_file’ : ‘file.txt’ , ‘DB’:’photcat’ , ‘OUT’:’csv’ , ‘SHORT’:’short’} r=requests.post(url,files=files,data=values) I’m filling the value … Read more

Python Request Post with param data

This is the raw request for an API call: POST http://192.168.3.45:8080/api/v2/event/log?sessionKey=b299d17b896417a7b18f46544d40adb734240cc2&format=json HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json Content-Length: 86 Host: 192.168.3.45:8080 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) {“eventType”:”AAS_PORTAL_START”,”data”:{“uid”:”hfe3hf45huf33545″,”aid”:”1″,”vid”:”1″}}””” This request returns a success (2xx) response. Now I am trying to post this request using requests: >>> import requests >>> headers = {‘content-type’ : ‘application/json’} >>> data … Read more

SSL InsecurePlatform error when using Requests package

Im using Python 2.7.3 and Requests. I installed Requests via pip. I believe it’s the latest version. I’m running on Debian Wheezy. I’ve used Requests lots of times in the past and never faced this issue, but it seems that when making https requests with Requests I get an InsecurePlatform exception. The error mentions urllib3, … Read more

Max retries exceeded with URL in requests

I’m trying to get the content of App Store > Business: import requests from lxml import html page = requests.get(“https://itunes.apple.com/in/genre/ios-business/id6000?mt=8”) tree = html.fromstring(page.text) flist = [] plist = [] for i in range(0, 100): app = tree.xpath(“//div[@class=”column first”]/ul/li/a/@href”) ap = app[0] page1 = requests.get(ap) When I try the range with (0,2) it works, but when … Read more