Merhaba arkadaşlar kafamda denemek istediğim bir raspberry projesi var. İlk defa deneyeceğim böyle bir iş.
Şu arkadaştan özendim doğrusu raspi ile kendine plaket yapıyor. Dedim bu adam bu verileri çekiyorsa bende gün boyu vdslerde olan adsenselere erişemiyorum, masnın üstüne koyarım ekranı veririm apiyi kazançları gösteririm dedim.
https://www.youtube.com/watch?v=09OjXKzsNvY
Ama tabiki kod bilgim kısıtlı.
İnterntte adamlar API leri çekerek script yazmışlar:
https://github.com/googleads/googlea...ster/v2/python burdan bu dosyaları indirdim.
Google kendi sitesinde de şöyle metrikler vermiş:
https://developers.google.com/adsens...rest/v2/Metric
Şimdi ben hesabımı apiye açtım, bir şekilde pythona bagladım ve scripti çalıştırdımda o ay ne kadar kazandığım, hesap ismi ve o yukarda paylaştığım github linkinde python ile ne kadar dosya görüyorsanız o verileri çekiyor. Ama python ve bu api lerin nasıl çekildiğine dair hiç bir fikrim olmadığı için yine yukarıda belirttiğim google'da çekebileceğim diğer metrikleri nasıl çekerim nasıl kod yazmam gerek hiç ama hiç fikrim yok.
Örneğin şu .py dosyası ile kesinleşen ücretimi görebiliyorum:
#!/usr/bin/python
#
# Copyright 2021 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Gets all payments available for the logged in user's default account.
Tags: accounts.payments.list
"""
import adsense_util
import datetime
import sys
import google.auth.exceptions
from googleapiclient import discovery
def main(argv):
# Authenticate and construct service.
credentials = adsense_util.get_adsense_credentials()
with discovery.build('adsense', 'v2', credentials = credentials) as service:
try:
# Select and retrieve account.
account_id = adsense_util.get_account_id(service)
# Retrieve ad client list in pages and display data as we receive it.
request = service.accounts().payments().list(parent=account_id)
if request is not None:
result = request.execute()
if 'payments' in result:
for payment in result['payments']:
if 'date' in payment:
payment_date = datetime.date(
payment['date']['year'],
payment['date']['month'],
payment['date']['day']).strftime('%Y-%m-%d')
else:
payment_date = 'unknown'
print('Payment with ID "%s" of %s and date %s was found' % (
payment['name'], payment['amount'], payment_date))
else:
print('No payments found.')
except google.auth.exceptions.RefreshError:
print('The credentials have been revoked or expired, please delete the '
'"%s" file and re-run the application to re-authorize.' %
adsense_util.CREDENTIALS_FILE)
if __name__ == '__main__':
main(sys.argv)Ben burdaki hiç bir satırı anlamadım ve "ESTIMATED_EARNINGS" metriğini nasıl satıra dökebileceğime dair bir fikrim yok çok uğraştım ama bulamadım kaynakta yok yerli yabancı. Bulduklarım yukardakiler zaten. Acaba tek satır rapberryim de görünecek şekilde günlük kazanç metriğini nasıl çekebilirim?