unytics / bigfunctions

Supercharge BigQuery with BigFunctions
https://unytics.io/bigfunctions/
MIT License
604 stars 56 forks source link

[new] `get_appstore_data(url)` #18

Open unytics opened 1 year ago

unytics commented 1 year ago
with content as (
  select bigfunctions.eu.get('https://play.google.com/store/apps/details?id=com.fpe.comptenickel&hl=en&gl=US', null) as text
)

select 
  to_json_string(
    struct(
      cast(regexp_extract(text, r'Rated (\d\.\d) stars out of five stars') as float64) as rating,
      ifnull(
        ifnull(
          cast(1000000 * cast(regexp_extract(text, r'(\d+\.\d)M reviews') as float64) as int64),
          cast(1000 * cast(regexp_extract(text, r'(\d+\.\d)K reviews') as float64) as int64)
        ),
        cast(regexp_extract(text, r'(\d+\.\d) reviews') as int64)
       ) as nb_reviews
    )
  ) as infos
from content
unytics commented 1 year ago

Tester pour:

shivam221098 commented 1 year ago

Hi 👋,

Is that function can be made more dynamic for Playstore or Appstore? i.e. It's not a good idea to pass in URLs of apps to get the count of reviews, ratings, etc. Someone still has to get the URL of the app's page first then only he can use it in the functions calls. If someone can get the URL then he can also get the review and rating from the page and use it for their purpose.

What if

  1. It can be made for two types of inputs a. If an input is a type of URL (use regex to check) then use your query. b. If an input is a type of non-URL then search for that phrase on Appstore or Playstore.
  2. For non-URL types we can search for that phrase on the official Playstore or Appstore and extract reviews and ratings from the top matched result.