본문 바로가기
QA/Test Automation

[Apptweak][iOS] 검색어 포함된 리뷰만 추출하기

by 화뉘 2021. 12. 6.
import datetime
from dateutil.relativedelta import relativedelta
import json
import requests
import sys
import warnings
from requests.packages.urllib3.exceptions import InsecureRequestWarning

warnings.simplefilter('ignore', InsecureRequestWarning)

now = datetime.datetime.now()
nowDate = now.strftime('%Y-%m-%d')
print(nowDate)
yesterday = now - relativedelta(days=1)
yesterdayDate = yesterday.strftime('%Y-%m-%d')
print(yesterdayDate)
agoweek = now - relativedelta(weeks=1)
agoweekDate = agoweek.strftime('%Y-%m-%d')
print(agoweekDate)
agomonth = now - relativedelta(months=1)
agomonthDate = agomonth.strftime('%Y-%m-%d')
print(agomonthDate)
result_size = 100
review_term = "검색어"

url = "https://api.apptweak.com/ios/applications/package_id/reviews/filter/list.json"

params = {"country":"kr","min_rating":1,"max_rating":5,"start_date":agoweekDate2,"end_date":yesterdayDate2,"term":review_term,"from":1,"size":100}

headers = {
    'X-Apptweak-Key': "token_key",
    'cache-control': "no-cache",
    'Postman-Token': "token_key"
    }

response = requests.request("GET", url, headers=headers, params=params, verify=False).text
print(response)

f = open("review_term_and.json", "w")
f.write(response)
f.close()

댓글