mail@pastecode.io avatarunknown
2 months ago
1.7 kB
import pandas as pd
from google_play_scraper import app, reviews
from bs4 import BeautifulSoup
import requests
def get_additional_info(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.content, 'html.parser')
    # Example: Extracting the app's description
    description = soup.find('div', jsname='sngebd').text.strip()

    return description
def get_app_reviews(app_id):
    # Fetch app details using "google-play-scraper"
    app_details = app(app_id)
    app_title = app_details['title']

    # Fetch app reviews using "google-play-scraper"
    review_data, _ = reviews(app_id, lang='tr', count=5000, sort='NEWEST')

    return app_title, review_data

def save_reviews_to_excel(app_title, review_data, output_file):
    data = []

    for review in review_data:
            "User": review.get("userName"),
            "Rating": review.get("score"),
            "Comment": review.get("content"),
            "Date": review.get("at"),

    df = pd.DataFrame(data)
    df.to_excel(output_file, index=False)

if __name__ == "_main_":
    # Replace this with the actual app ID of the app whose reviews you want to fetch
    app_id = "com.tmob.teknosa"

    print("My debug line beforee output it's  working??")
    output_file = "reviews_data1.xlsx"

    app_title, review_data = get_app_reviews(app_id)
    save_reviews_to_excel(app_title, review_data, output_file)

    # Example: Extract additional information using BeautifulSoup
    app_url = f"https://play.google.com/store/apps/details?id={app_id}"
    """additional_info = get_additional_info(app_url)"""
    print(f"Reviews data for '{app_title}' successfully saved to '{output_file}'.")