Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- googleUpdates = ["2019-11-20", "2019-03-01", "2018-08-01"]
- domains = ["amazon.com", "sistrix.com"]
- baseUrl = "https://api.sistrix.com/domain.sichtbarkeitsindex?api_key=S6wam3Uq3KdcuEHYb4nSTmR8EhapBjjj&format=json"
- def calculateTrend(date1, date2):
- perc = (date1 / date2) * 100
- return round(perc - 100, 1)
- myDict = {}
- for domain in domains:
- i = 0
- while i < len(googleUpdates) - 1:
- url1 = f"{baseUrl}&domain={domain}&date={googleUpdates[0]}"
- url2 = f"{baseUrl}&domain={domain}&date={googleUpdates[i+1]}"
- df1 = requests.get(url1).json()["answer"][0]["sichtbarkeitsindex"][0]["value"]
- df2 = requests.get(url2).json()["answer"][0]["sichtbarkeitsindex"][0]["value"]
- trend = f"{calculateTrend(df1, df2)}%"
- if domain in myDict:
- myDict[domain].append(trend)
- else:
- myDict[domain] = [trend]
- i += 1
- print(myDict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement