1

I am new to using the Facebook-analytics export api, and was wondering if someone could help me troubleshoot my current issue. I am trying to follow the following link to download the event data that is being generated through the Facebook-analytics sdk on my mobile app.

https://developers.facebook.com/docs/analytics/export#download-file

I have been able to correctly execute steps one and two using the python requests library, but I am having trouble with step three. For some reason when I make the http call using requests to download the file, the content that is return from the GET call is a bunch of html code that does not look like the example event data in the link above. Here is the requests calls I am making:

creates request

access_token = '######ACCESS_TOKEN######'
start_ts = '1495322078'
end_ts = '1495408478'

def get_fb_token(app_id, app_secret):           
    payload = {'access_token': access_token, 'start_ts': start_ts, 'end_ts': end_ts}
    file = requests.post('https://graph.facebook.com/v2.6/#####FBAPP_ID#######/analytics_app_events_exports', params = payload)

query all exports

payload = {'access_token': access_token}
file = requests.get('https://graph.facebook.com/v2.6/#####FBAPP_ID#######/analytics_app_events_exports?access_token', params = payload)

download export file

id = '###EXPORT_ID#####'
filename = 'output.gz'
access_token = '####ACCESS_TOKEN#######'
payload = {'access_token': access_token, 'id': id, 'filename': filename}
file = requests.get('https://lookaside.fbsbx.com/analytics/app_events_export/download', params = payload)

Am I missing something? The data from step three should be in file.content correct? Where is output.gz being saved to?

here are the headers that are associated to file.headers:

{'X-XSS-Protection': '0', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Expires': 'Sat, 01 Jan 2000 00:00:00 GMT', 'public-key-pins-report-only': 'max-age=500; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="; pin-sha256="q4PO2G2cbkZhZ82+JgmRUyGMoAeozA+BSXVXQWB8XWQ="; report-uri="http://reports.fb.com/hpkp/"', 'Vary': 'Accept-Encoding', 'X-FB-Debug': '6ILkaUGMgE6MsB3PXIrxWT+c2PhWNrMGocvhbBcIYzakj4LoI1U+K+A5AFt7EpTe7PtrtbQ3gneI8PS0HIOFDw==', 'Date': 'Wed, 24 May 2017 01:22:17 GMT', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'private, no-cache, no-store, must-revalidate', 'Strict-Transport-Security': 'max-age=15552000; preload', 'Access-Control-Allow-Origin': '*', 'Content-Type': 'text/html', 'X-Frame-Options': 'DENY'}

here is a sample of the html content that is returned from file.content:

'\n\nwindow._cstart=+new Date();function envFlush(a){function b(c){for(var d in a)c[d]=a[d];}if(window.requireLazy){window.requireLazy([\'Env\'],b);}else{window.Env=window.Env||{};b(window.Env);}}envFlush({"ajaxpipe_token":"AXgRLglhFB9mLdIE","timeslice_heartbeat_config":{"pollIntervalMs":33,"idleGapThresholdMs":60,"ignoredTimesliceNames":{"requestAnimationFrame":true,"Event listenHandler mousemove":true,"Event listenHandler mouseover":true,"Event listenHandler mouseout":true,"Event listenHandler scroll":true},"enableOnRequire":false},"shouldLogCounters":true,"timeslice_categories":{"react_render":true,"reflow":true},"dom_mutation_flag":true});DEV=0;CavalryLogger=window.CavalryLogger||function(a){this.lid=a;this.transition=false;this.metric_collected=false;this.is_detailed_profiler=false;this.instrumentation_started=false;this.pagelet_metrics={};this.events={};this.ongoing_watch={};this.values={t_cstart:window._cstart};this.piggy_values={};this.bootloader_metrics={};this.resource_to_pagelet_mapping={};this.e2eLogged=false;if(this.initializeInstrumentation)this.initializeInstrumentation();};CavalryLogger.prototype.setIsDetailedProfiler=function(a){this.is_detailed_profiler=a;return this;};CavalryLogger.prototype.setTTIEvent=function(a){this.tti_event=a;return this;};CavalryLogger.prototype.setValue=function(a,b,c,d){var e=d?this.piggy_values:this.values;if(typeof e[a]==\'undefined\'||c)e[a]=b;return this;};CavalryLogger.prototype.getLastTtiValue=function(){return this.lastTtiValue;};CavalryLogger.prototype.setTimeStamp=CavalryLogger.prototype.setTimeStamp||function(a,b,c,d){this.mark(a);var e=this.values.t_cstart||this.values.t_start,f=d?e+d:CavalryLogger.now();this.setValue(a,f,b,c);if(this.tti_event&&a==this.tti_event){this.lastTtiValue=f;this.setTimeStamp(\'t_tti\',b);}return this;};CavalryLogger.prototype.mark=typeof console===\'object\'&&console.timeStamp?function(a){console.timeStamp(a);}:function(){};CavalryLogger.prototype.addPiggyback=function(a,b){this.piggy_values[a]=b;return this;};CavalryLogger.instances={};CavalryLogger.id=0;CavalryLogger.perfNubMarkup="";CavalryLogger.getInstance=function(a){if(typeof a==\'undefined\')a=CavalryLogger.id;if(!CavalryLogger.instances[a])CavalryLogger.instances[a]=new CavalryLogger(a);return CavalryLogger.instances[a];};CavalryLogger.setPageID=function(a){if(CavalryLogger.id===0){var b=CavalryLogger.getInstance();CavalryLogger.instances[a]=b;CavalryLogger.instances[a].lid=a;delete CavalryLogger.instances[0];}CavalryLogger.id=a;};CavalryLogger.setPerfNubMarkup=function(a){CavalryLogger.perfNubMarkup=a;};CavalryLogger.now=function(){if(window.performance&&performance.timing&&performance.timing.navigationStart&&performance.now)return performance.now()+performance.timing.navigationStart;return new Date().getTime();};CavalryLogger.prototype.measureResources=function(){};CavalryLogger.prototype.profileEarlyResources=function(){};CavalryLogger.getBootloaderMetricsFromAllLoggers=function(){};CavalryLogger.start_js=function(){};CavalryLogger.done_js=function(){};CavalryLogger.getInstance().setTTIEvent("t_domcontent");CavalryLogger.prototype.measureResources=function(a,b){if(!this.log_resources)return;var c=\'bootload/\'+a.name;if(this.bootloader_metrics[c]!==undefined||this.ongoing_watch[c]!==undefined)return;var d=CavalryLogger.now();this.ongoing_watch[c]=d;if(!(\'start_\'+c in this.bootloader_metrics))this.bootloader_metrics[\'start_\'+c]=d;if(b&&!(\'tag_\'+c in this.bootloader_metrics))this.bootloader_metrics[\'tag_\'+c]=b;if(a.type===\'js\'){var e=\'js_exec/\'+a.name;this.ongoing_watch[e]=d;}};CavalryLogger.prototype.stopWatch=function(a){if(this.ongoing_watch[a]){var b=CavalryLogger.now(),c=b-this.ongoing_watch[a];this.bootloader_metrics[a]=c;var d=this.piggy_values;if(a.indexOf(\'bootload\')===0){if(!d.t_resource_download)d.t_resource_download=0;if(!d.resources_downloaded)d.resources_downloaded=0;d.t_resource_download+=c;d.resources_downloaded+=1;if(d[\'tag_\'+a]==\'EF\')d.t_pagelet_cssload_early_resources=b;}delete this.ongoing_watch[a];}return this;};CavalryLogger.getBootloaderMetricsFromAllLoggers=function(){var a={};Object.values(window.CavalryLogger.instances).forEach(function(b){if(b.bootloader_metrics)Object.assign(a,b.bootloader_metrics);});return a;};CavalryLogger.start_js=function(a){for(var b=0;bEF\');};CavalryLogger.getInstance().log_resources=true;CavalryLogger.getInstance().setIsDetailedProfiler(true);window.CavalryLogger&&CavalryLogger.getInstance().setTimeStamp("t_start");Facebook\n\n\n\nrequire("TimeSlice").guard(function() {(require("ServerJSDefine")).handleDefines([["FluxConfig",[],{"ads_improve_perf_flux_container_subscriptions":false},2434],["PresenceInitialData",[],{"cookiePollInterval":500,"cookieVersion":3,"serverTime":"1495581411000","shouldSuppress":false,"useWebStorage":false},57],["RTCConfig",[],{},760],["MarketplaceSEOUtils",[],{"canonicalBaseURL":"https:\/\/www.facebook.com"},2231],["DateFormatConfig",[],{"numericDateOrder":["m","d","y"],"numericDateSeparator":"\/","shortDayNames":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"timeSeparator":":","weekStart":6,"formats":{"D":"D","D g:ia":"D g:ia","D M d":"D M d","D M d, Y":"D M d, Y","D M j":"D M j","D M j, g:ia":"D M j, g:ia","D M j, y":"D M j, y","D M j, Y g:ia":"D M j, Y g:ia","D, M j, Y":"D, M j, Y","F d":"F d","F d, Y":"F d, Y","F g":"F g","F j":"F j","F j, Y":"F j, Y","F j, Y \u0040 g:i A":"F j, Y \u0040 g:i A","F j, Y g:i a":"F j, Y g:i a","F jS":"F jS","F jS, g:ia":"F jS, g:ia","F jS, Y":"F jS, Y","F Y":"F Y","g A":"g A","g:i":"g:i","g:i A":"g:i A","g:i a":"g:i a","g:iA":"g:iA","g:ia":"g:ia","g:ia F jS, Y":"g:ia F jS, Y","g:iA l, F jS":"g:iA l, F jS","g:ia M j":"g:ia M j","g:ia M jS":"g:ia M jS","g:ia, F jS":"g:ia, F jS","g:iA, l M jS":"g:iA, l M jS","g:sa":"g:sa","H:I - M d, Y":"H:I - M d, Y","h:i a":"h:i a","h:m:s m\/d\/Y":"h:m:s m\/d\/Y","j":"j","l F d, Y":"l F d, Y","l g:ia":"l g:ia","l, F d, Y":"l, F d, Y","l, F j":"l, F j","l, F j, Y":"l, F j, Y","l, F jS":"l, F jS","l, F jS, g:ia":"l, F jS, g:ia","l, M j":"l, M j","l, M j, Y":"l, M j, Y","l, M j, Y g:ia":"l, M j, Y g:ia","M d":"M d","M d, Y":"M d, Y","M d, Y g:ia":"M d, Y g:ia","M d, Y ga":"M d, Y ga","M j":"M j","M j, Y":"M j, Y","M j, Y g:i A":"M j, Y g:i A","M j, Y g:ia":"M j, Y g:ia","M jS, g:ia":"M jS, g:ia","M Y":"M Y","M y":"M y","m-d-y":"m-d-y","M. d":"M. d","M. d, Y":"M. d, Y","j F Y":"j F Y","m.d.y":"m.d.y","m\/d":"m\/d","m\/d\/Y":"m\/d\/Y","m\/d\/y":"m\/d\/y","m\/d\/Y g:ia":"m\/d\/Y g:ia","m\/d\/y H:i:s":"m\/d\/y H:i:s","m\/d\/Y h:m":"m\/d\/Y h:m","n":"n","n\/j":"n\/j","n\/j, g:ia":"n\/j, g:ia","n\/j\/y":"n\/j\/y","Y":"Y","Y-m-d":"Y-m-d","Y\/m\/d":"Y\/m\/d","y\/m\/d":"y\/m\/d","j \/ F \/ Y":"j \/ F \/ Y"},"ordinalSuffixes":{"1":"st","2":"nd","3":"rd","4":"th","5":"th","6":"th","7":"th","8":"th","9":"th","10":"th","11":"th","12":"th","13":"th","14":"th","15":"th","16":"th","17":"th","18":"th","19":"th","20":"th","21":"st","22":"nd","23":"rd","24":"th","25":"th","26":"th","27":"th","28":"th","29":"th","30":"th","31":"st"}},165],["ViewerContextDateData",[],{"gks":{"date_time_force_legacy_api":false}},1411],["RTISubscriptionManagerConfig",[],{"config":{"max_subscriptions":150,"www_idle_unsubscribe_min_time_ms":600000,"www_idle_unsubscribe_times_ms":{"feedback_like_subscribe":600000,"comment_like_subscribe":600000,"feedback_typing_subscribe":600000,"comment_create_subscribe":1800000},"autobot_tiers":{"latest":"realtime.skywalker.autobot.latest","intern":"realtime.skywalker.autobot.intern","sb":"realtime.skywalker.autobot.sb"}},"autobot":{},"assimilator":{},"unsubscribe_release":true},1081],["LocaleInitialData",[],{"locale":"en_US","language":"English (US)"},273],["MessengerURIConstants",[],{"ARCHIVED_PATH":"\/archived","COMPOSE_SUBPATH":"\/new","GROUPS_PATH":"\/groups","PEOPLE_PATH":"\/people","SUPPORT_PATH":"\/support","FILTERED_REQUESTS_PATH":"\/filtered","MESSAGE_REQUESTS_PATH":"\/requests","THREAD_PREFIX":"\/t\/","GROUP_PREFIX":"group-","FACEBOOK_PREFIX":"\/messages"},1912],["PresencePrivacyInitialData",[],{},58],["MercuryParticipantsConstants",[],{"UNKNOWN_GENDER":0,"EMAIL_IMAGE":"\/images\/messaging\/threadlist\/envelope.png","IMAGE_SIZE":32,"BIG_IMAGE_SIZE":50},109],["MessagingConfig",[],{"SEND_CONNECTION_RETRIES":2,"syncFetchRetries":2,"syncFetchInitialTimeoutMs":1500,"syncFetchTimeoutMultiplier":1.2,"syncFetchRequestTimeoutMs":10000},97],["MercuryServerRequestsConfig",[],{"sendMessageTimeout":45000},107],["FantailConfig",["FantailLogQueue"],{"FantailLogQueue":{"__m":"FantailLogQueue"}},1258],["PECurrencyConfig",[],{"currency_map_for_render":{"AED":{"format":"{amount} {symbol}","symbol":"\u062f.\u0625.","offset":100,"screen_name":"UAE Dirham"},"AMD":{"format":"{amount} {symbol}","symbol":"\u0564\u0580.","offset":100,"screen_name":null},"ANG":{"format":"{symbol}{amount}","symbol":"ANG","offset":100,"screen_name":null},"AOA":{"format":"{symbol}{amount}","symbol":"AOA","offset":100,"screen_name":null},"ARS":{"format":"{symbol} {amount}","symbol":"$","offset":100,"screen_name":"Argentine Peso"},"AUD":{"format":"{symbol}{amount}","symbol":"$","offset":100,"screen_name":"Australian Dollar"},"AWG":{"format":"{symbol}{amount}","symbol":"AWG","offset":100,"screen_name":null},"BAM":{"format":"{symbol}{amount}","symbol":"BAM","offset":100,"screen_name":null},"BBD":{"format":"{symbol}{amount}","symbol":"Bds$","offset":100,"screen_name":null},"BDT":{"format":"{symbol}{amount}","symbol":"\u09f3","offset":100,"screen_name":"Bangladeshi Taka"},"BGN":{"format":"{amount} {symbol}","symbol":"\u043b\u0432.","offset":100,"screen_name":"Bulgarian Lev"},"BHD":{"format":"{amount} {symbol}","symbol":"\u062f.\u0628.","offset":100,"screen_name":"Bahraini Dinar"},"BOB":{"format":"{symbol} {amount}","symbol":"Bs.","offset":100,"screen_name":"Bolivian Boliviano"},"BRL":{"format":"{symbol} {amount}","symbol":"R$","offset":100,"screen_name":"Brazilian Real"},"BYN":{"format":"{amount} {symbol}","symbol":"Br","offset":100,"screen_name":null},"CAD":{"format":"{symbol}{amount}","symbol":"$","offset":100,"screen_name":"Canadian Dollar"},"CHF":{"format":"{symbol} {amount}","symbol":"Fr.","offset":100,"screen_name":"Swiss Franc"},"CLP":{"format":"{symbol} {amount}","symbol":"$","offset":1,"screen_name":"Chilean Peso"},"CNY":{"format":"{symbol}{amount}","symbol":"\uffe5","offset":100,"screen_name":"Chinese Yuan"},"COP":{"format":"{symbol} {amount}","symbol":"$","offset":1,"screen_name":"Colombian Peso"},"CRC":{"format":"{symbol}{amount}","symbol":"\u20a1","offset":1,"screen_name":"Costa Rican Colon"},"CZK":{"format":"{amount} {symbol}","symbol":"K\u010d","offset":100,"screen_name":"Czech Koruna"},"DKK":{"format":"{amount} {symbol}","symbol":"kr.","offset":100,"screen_name":"Danish Krone"},"DZD":{"format":"{amount} {symbol}","symbol":"DA","offset":100,"screen_name":"Algerian Dinar"},"EGP":{"format":"{amount} {symbol}","symbol":"\u062c.\u0645.","offset":100,"screen_name":"Egyptian Pound"},"EUR":{"format":"{symbol} {amount}","symbol":"\u20ac","offset":100,"screen_name":"Euro"},"FBZ":{"format":"{symbol}{amount}","symbol":"C","offset":100,"screen_name":"credits"},"GBP":{"format":"{symbol}{amount}","symbol":"\u00a3","offset":100,"screen_name":"British Pound"},"GHS":{"format":"{symbol}{amount}","symbol":"GHS","offset":100,"screen_name":"Ghanaian Cedi"},"GTQ":{"format":"{symbol}{amount}","symbol":"Q","offset":100,"screen_name":"Guatemalan Quetzal"},"HKD":{"format":"{symbol}{amount}","symbol":"$","offset":100,"screen_name":"Hong Kong Dollar"},"HNL":{"format":"{symbol} {amount}","symbol":"L.","offset":100,"screen_name":"Honduran Lempira"},"HRK":{"format":"{amount} {symbol}","symbol":"kn","offset":100,"screen_name":"Croatian Kuna"},"HUF":{"format":"{amount} {symbol}","symbol":"Ft","offset":1,"screen_name":"Hungarian Forint"},"IDR":{"format":"{symbol} {amount}","symbol":"Rp","offset":1,"screen_name":"Indonesian Rupiah"},"ILS":{"format":"{symbol} {amount}","symbol":"\u20aa","offset":100,"screen_name":"Israeli New Shekel"},"INR":{"format":"{symbol} {amount}","symbol":"\u20b9","offset":100,"screen_name":"Indian Rupee"},"ISK":{"format":"{amount} {symbol}","symbol":"kr.","offset":1,"screen_name":"Iceland Krona"},"JOD":{"format":"{amount} {symbol}","symbol":"\u062f.\u0627.","offset":100,"screen_name":"Jordanian Dinar"},"JPY":{"format":"{symbol}{amount}","symbol":"\u00a5","offset":1,"screen_name":"Japanese Yen"},"KES":{"format":"{symbol}{amount}","symbol":"KSh","offset":100,"screen_name":"Kenyan Shilling"},"KRW":{"format":"{symbol}{amount}","symbol":"\u20a9","offset":1,"screen_name":"Korean Won"},"KWD":{"format":"{amount} {symbol}","symbol":"\u062f.\u0643.","offset":100,"screen_name":null},"KYD":{"format":"{symbol}{amount}","symbol":"CI$","offset":100,"screen_name":null},"LKR":{"format":"{symbol}{amount}","symbol":"LKR","offset":100,"screen_name":null},"LTL":{"format":"{amount} {symbol}","symbol":"Lt","offset":100,"screen_name":"Lithuanian Litas"},"LVL":{"format":"{symbol} {amount}","symbol":"Ls","offset":100,"screen_name":"Latvian Lats"},"MAD":{"format":"{amount} {symbol}","symbol":"\u062f.\u0645.","offset":100,"screen_name":null},"MOP":{"format":"{symbol}{amount}","symbol":"MOP","offset":100,"screen_name":"Macau Patacas"},"MUR":{"format":"{symbol}{amount}","symbol":"MUR","offset":100,"screen_name":null},"MVR":{"format":"","symbol":"\u0783.","offset":100,"screen_name":null},"MXN":{"format":"{symbol}{amount}","symbol":"$","offset":100,"screen_name":"Mexican Peso"},"MYR":{"format":"{symbol}{amount}","symbol":"RM","offset":100,"screen_name":"Malaysian Ringgit"},"MZN":{"format":"{symbol}{amount}","symbol":"MT","offset":100,"screen_name":null},"NGN":{"format":"{symbol}{amount}","symbol":"\u20a6","offset":100,"screen_name":"Nigerian Naira"},"NIO":{"format":"{symbol} {amount}","symbol":"C$","offset":100,"screen_name":"Nicaraguan Cordoba"},"NOK":{"format":"{symbol} {amount}","symbol":"kr","offset":100,"screen_name":"Norwegian Krone"},"NZD":{"format":"{amount}{symbol}","symbol":"$","offset":100,"screen_name":"New Zealand Dollar"},"OMR":{"format":"{amount} {symbol}","symbol":"\u0631.\u0639.","offset":100,"screen_name":null},"PAB":{"format":"{symbol} {amount}","symbol":"B\/.","offset":100,"screen_name":null},"PEN":{"format":"{symbol} {amount}","symbol":"S\/.","offset":100,"screen_name":"Peruvian Nuevo Sol"},"PHP":{"format":"{symbol}{amount}","symbol":"\u20b1","offset":100,"screen_name":"Philippine Peso"},"PKR":{"format":"{symbol}{amount}","symbol":"Rs","offset":100,"screen_name":"Pakistani Rupee"},"PLN":{"format":"{amount} {symbol}","symbol":"z\u0142","offset":100,"screen_name":"Polish Zloty"},"PYG":{"format":"{symbol} {amount}","symbol":"\u20b2","offset":1,"screen_name":"Paraguayan Guarani"},"QAR":{"format":"{amount} {symbol}","symbol":"\u0631.\u0642.","offset":100,"screen_name":"Qatari Rials"},"RON":{"format":"{amount} {symbol}","symbol":"lei","offset":100,"screen_name":"Romanian Leu"},"RSD":{"format":"{symbol}{amount}","symbol":"RSD","offset":100,"screen_name":"Serbian Dinar"},"RUB":{"format":"{amount} {symbol}","symbol":"p.","offset":100,"screen_name":"Russian Ruble"},"SAR":{"format":"{amount} {symbol}","symbol":"\u0631.\u0633.","offset":100,"screen_name":"Saudi Arabian Riyal"},"SEK":{"format":"{amount} {symbol}","symbol":"kr","offset":100,"screen_name":"Swedish Krona"},"SGD":{"format":"{symbol}{amount}","symbol":"$","offset":100,"screen_name":"Singapore Dollar"},"SKK":{"format":"{amount} {symbol}","symbol":"Sk","offset":100,"screen_name":"Slovak Koruna"},"SRD":{"format":"{symbol}{amount}","symbol":"SRD","offset":100,"screen_name":null},"THB":{"format":"{symbol}{amount}","symbol":"\u0e3f","offset":100,"screen_name":"Thai Baht"},"TRY":{"format":"{amount} {symbol}","symbol":"TL","offset":100,"screen_name":"Turkish Lira"},"TWD":{"format":"{symbol}{amount}","symbol":"NT$","offset":1,"screen_name":"Taiwan Dollar"},"TZS":{"format":"{symbol}{amount}","symbol":"TSh","offset":1,"screen_name":"Tanzanian Shilling"},"UAH":{"format":"{amount} {symbol}","symbol":"\u0433\u0440\u043d.","offset":100,"screen_name":"Ukrainian Hryvnia"},"USD":{"format":"{symbol}{amount}","symbol":"$","offset":100,"screen_name":"US Dollars"},"UYU":{"format":"{symbol} {amount}","symbol":"$U","offset":100,"screen_name":"Uruguay Peso"},"VEF":{"format":"{symbol} {amount}","symbol":"Bs","offset":100,"screen_name":"Venezuelan Bolivar"},"VND":{"format":"{amount} {symbol}","symbol":"\u20ab","offset":1,"screen_name":"Vietnamese Dong"},"XAF":{"format":"{symbol}{amount}","symbol":"FCFA","offset":1,"screen_name":null},"XOF":{"format":"{symbol}{amount}","symbol":"FCFA","offset":1,"screen_name":null},"ZAR":{"format":"{symbol} {amount}","symbol":"R","offset":100,"screen_name":"South African Rand"}},"currency_map_for_cc":{"AED":{"format":"{amount} {symbol}","symbol":"\u062f.\u0625.","offset":100,"screen_name":"UAE Dirham"},"ARS":{"format":"{symbol} {amount}","symbol":"$","offset":100,"screen_name":"Argentine

file.content with headers = {'content-type' : 'application/json'}:

'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\xe5\x99Yo\xe2X\x10\x85\xdf\xe7W\xb4x\xf6\xa5\xefRw\xa9\xc7{\xbd\xbcLw:\x1a\x927$d\xc0\xccXML\x86e&\xf9\xf7S\x06BB:\xa41\xc9\xc4H\x1d!\xb1\x842\xf0q\xea\xd4)#\x005p\xad\x84\x8e&\xc3\xc1\xcdlXN\x8b\xc1\xb8\xc8G\xcb\xf2\x9f|Y\x0c\xf2\xdb\xdb\xa8\x9c-\x06\xab\xea{5\xfb\xb7\x8ad\x97\xf3\xc8p\xc3\xe9JP\xadBc\xb8\x8d:\xb2\x13u\xae\xab\xd14_,\xcaIY\x8c\xe9\xee\xa2\xa0\xdb\xb3j\xf0\xf7*\xaf\x96\xf9\x00:Q\xff\xe2\x1d.\xcb\xf9\xaa\xa8\xaf;Y(\xbf\xf5z\xc9\xef]\xe8\n\xdb\xe5\x9f\xaf\xabry\xdf\xb5]\xec\xd2Ku\xca\xcb|\x0c\xfd\xc8\xd67\xbf\xf5>\t\xdeU]\xd1\x89\xfcM1/G\xf9\xe7\xaf\xb3j9/\xf2it1\x8b\xf3\xf9\xbc,\xe6\x91\xe0\x12\xee\xacqw\xeb\xcfH@dT\xcd\x06\xab2\x9a\xe4\xd3E\x119\xa7\x94I0f\xca\x9a\x94A\xc0\x84yI\xb7\x9cKP\xa56\x86\xd8\xcb\xdf\xc4K8_\x87I\x1f\xe5\xa1js\xef\x1d/g\xcfJI\xa7%6eUW\th\x8f\x95\xecG\xb0e\x85\x84J\x1f\x87J\xacQ\xa9H\xed\xa1\xf2\xb13&s\x9c\x01\x82g\xa0\xe2\xc0\xbcN\x02\xb3)\x80\xe5\x021\xcbp#+\xa3QA\x83.\x05-\xe4\xaeM\x1d\n\x83Q\x87\xff\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\x8fo{\xc2\xeb_\xecT\'\xff\xc7\xed\xfa\x9c\x85\x05\xa2\x0ei\r\xce\xefH\xb4\x8f\x9b\xa4Ud\x87\xe7\xf9\x93R\x1bS\x94\xfeeOhR\xa4\xe0\xd2^\x93\xbe0B\x8f\x0e\xfc\x94\xccp\xff\xc4\xa2G\x9a\x10I\xa2Y&i?\x82\x14\xc3D\x02\xb5\xa9W\x9a`A\x08|;K\x15\x99S\x13\xe1\xd5st\xa7<\xca\xb2\xa4<\xd1\xc6\x9c8\xd7]\xf39\xd0#\xc3\x89\x02\xdd\xe2\xae\xd9\x02\xac\xff\x00\xbb!gr\xf1"\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00'

bob
  • 31
  • 4

1 Answers1

0

Output.gz should be saved to the same directory where you are running your Python script. Is it not there? If you are getting HTML as a response you may need to set the content encoding header of the get request to accept gzip files (which should automatically decompress the file).

You need to iterate through the response to store it in output.gz. Here is a really good example: Downloading *.gz zipped file with python requests corrupt it

jasonleehodges
  • 191
  • 2
  • 13
  • The gzip file does not get saved in the working directory. What would the accept header parameters look like? – bob May 24 '17 at 01:20
  • Here's the documentation on the requests module that shows how to add a header. What is the HTML that is returned? Most of the time when I see HTML returned when I expected JSON or a file type it's because the HTML is some type of error page that will give me a clue as to what I did wrong in structuring the request. http://docs.python-requests.org/en/master/user/advanced/ – jasonleehodges May 24 '17 at 01:25
  • i added a sample of the html output. – bob May 24 '17 at 01:35
  • I also added the headers from file.headers – bob May 24 '17 at 01:47
  • Yeah the content type looks like it's set to text/HTML. Might need to be Content-Type: application/javascript – jasonleehodges May 24 '17 at 02:02
  • You might also consider checking what file.text returns. – jasonleehodges May 24 '17 at 02:15
  • changing the content-type to application/javascript or application/json did not seem to work. and how would iterating through the request content change the data in the request? I tried iterating the same way the thread to linked me to and saving to a .txt and .gz file and it just saved the same content in file.content :( – bob May 24 '17 at 02:17
  • I was just suggesting that if you wanted to save the result to output.gz you would need to iterate through the response. It's definitely returning a JSON object at some point but there's a bunch of JavaScript the precedes the JSON objects. What does file.text return, anything more simple? – jasonleehodges May 24 '17 at 02:19
  • file.text returns the same thing – bob May 24 '17 at 02:22