php - How to write curl get request on python to decrease parsing time -


i have basic curl request work site api in php:

$headers = array(   "content-type: text/xml;charset=\"windows-1251\"",   "host:api.content.com",   "accept:*/*",   "authorization:qwerty" );  $ch = curl_init(); curl_setopt($ch, curlopt_url,"https://api.content.com/v1.xml"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 60); curl_setopt($ch, curlopt_autoreferer, true); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_ssl_verifypeer, false);  $data = curl_exec($ch); $f = new simplexmlelement($data);  #echo $data; $total = $f['total']; curl_close($ch); } 

what best way write in python in case, request used in separate subprocesses decrease parsing time?

you can use requests, requests document;

>>> import json >>> url = 'https://api.github.com/some/endpoint' >>> payload = {'some': 'data'} >>> headers = {'content-type': 'application/json'}  >>> r = requests.post(url, data=json.dumps(payload), headers=headers) 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -