0

I am attempting to use Advanced web rankings api to download rankings information.

import requests
#enter data for request URL

print('information for URL creation')

#getProjectName

projectName = raw_input('ProjectName')

#getApiToken

apiToken = ""

#getStartDate

 startDate = raw_input('Start Date')

 #getStopDate

 stopDate = raw_input('Stop Date')

 url = "https://api.awrcloud.com/get.php?
 action=export_ranking&project=%s&token=%s&startDate=%s&stopDate=%s" % 
 (projectName,apiToken,startDate,stopDate)

 print(url)

    #https://api.awrcloud.com/get.php?
        #action=export_ranking&
        #project=project+name&
        #token=myAPItoken
        #&startDate=2013-07-23
        #&stopDate=2013-12-27

exportLink = requests.get(url).content

which gets the correct response something like:

 OK
 https://api.awrcloud.com/get.php?
 action=get_export&token=myAPItoken&project=project+name&fileName=2013-07-
  23-2013-12-27

how do i get the link to automatically open and begin a download. When i click on it it works correctly and begins the download.

Harrada
  • 83
  • 2
  • 8

1 Answers1

0

I'm guessing that you're getting that when you do print(exportLink) because exportLink is a Response object and not the actual content. You would want to use exportLink.text, exportLink.content, or if they send you JSON, something like exportLink.json()['blah'] and then parse the link.

Dean W.
  • 622
  • 5
  • 6