Pokemon GO whirlwinds are happening all over the world. I wrote a script for lunch that will call you as soon as the Japanese version of Pokemon GO is released. This is the fastest Pokemon get (・ ㅂ ・) و
Get status by polling itunes page via HTTP communication + Call with Twilio
When I checked Niantic's Pokemon Official HP on July 15, the iOS version has not been released, and the Android version has already been released. The Android version is filtered on the software side and it seems that Japanese users cannot play it.
appstore.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import requests
def app_store_is_open(_id):
"""
True if the Japanese App Store is open
:param _id: str
:rtype: bool
"""
headers = {'Content-type': 'application/json; charset=utf-8'}
url_base = "https://itunes.apple.com/jp/app/apple-store/{}?ct=official&mt=8"
url = url_base.format(_id)
response = requests.get(url, headers=headers)
assert response.status_code == 200 #HTTP Status is 200
return "Customer reviews" in response.text #There is a customer review item for open apps
ids = {
"POKEMON GO": "id1094591345",
"White cat": "id895687962",
"Puzzle": "id493470467",
"Granblue fantasy": "id852882903",
}
for k, v in ids.items():
print("{}: {}".format(k, app_store_is_open(v)))
Execution result
$ python appstore.py
Granblue fantasy: True
POKEMON GO: False
Puzzle: True
White cat: True
In Japan, we make calls using the Twilio API, a telephone-related venture that is developing in collaboration with AU.
tel.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from twilio.rest import TwilioRestClient
ACCOUNT_SID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
AUTH_TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
FROM_CALL_NUMBER = "819012341234"
TO_CALL_NUMBER = "819012341234"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
call = client.calls.create(to=TO_CALL_NUMBER, from_=FROM_CALL_NUMBER,
url="http://foo.com/call.xml")
print call.sid
Execution result
$ python tel.py
CA8b5ea1f08503ee8efc6aXXXXXXXX
I got a call. The phone keeps vibrating for about 30 seconds.
Combine the two scripts to complete the script that will call you when the App Store version of Pokemon GO is released.
poke_check.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import requests
from twilio.rest import TwilioRestClient
def app_store_is_open(_id):
"""
True if the Japanese App Store is open
:param _id: str
:rtype: bool
"""
headers = {'Content-type': 'application/json; charset=utf-8'}
url_base = "https://itunes.apple.com/jp/app/apple-store/{}?ct=official&mt=8"
url = url_base.format(_id)
response = requests.get(url, headers=headers)
assert response.status_code == 200 #HTTP Status is 200
return "Customer reviews" in response.text
def tel():
ACCOUNT_SID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
AUTH_TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
FROM_CALL_NUMBER = "819012341234"
TO_CALL_NUMBER = "819012341234"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
call = client.calls.create(to=TO_CALL_NUMBER, from_=FROM_CALL_NUMBER,
url="http://foo.com/call.xml")
def start():
print("start")
pokemon_go = "id1094591345"
if app_store_is_open(pokemon_go):
print("OPEN")
tel()
else:
print("NOT OPEN")
if __name__ == '__main__':
start()
Execution result
$ python poke_check.py
start
NOT OPEN
I hope it opens soon
There are people who are doing the same thing ... http://qiita.com/touyoubuntu/items/af5d8e9e69e099945da1
Recommended Posts