首页 > 解决方案 > App-Store-Review-Scraping:AppStoreScraper 无法识别 app-id

问题描述

我是编码方面的新手,今年夏天才开始。我正在尝试从 App Store 中抓取 9 个 live-shopping-apps 的评论:https ://www.apple.com/us/search/live-shopping?src=globalnav

我创建了一个包含有关应用程序信息的 xlsx 文件,并将其作为 csv 下载到代码中,希望 appstorescraper 能够通过其 id 识别应用程序,但它似乎不起作用。这是最初从https://python.plainenglish.io/scraping-app-store-reviews-with-python-90e4117ccdfb检索到的代码:

import pandas as pd

# for scraping app info from App Store
from itunes_app_scraper.scraper import AppStoreScraper

# for scraping app reviews from App Store
from app_store_scraper import AppStore

# for pretty printing data structures
from pprint import pprint

# for keeping track of timing
import datetime as dt
from tzlocal import get_localzone

# for building in wait times
import random
import time

## Read in file containing app names and IDs
app_df = pd.read_csv('Data/app_.....ids.csv')
app_df.head()


app_name    iOS_app_name    iOS_app_id  url
4   Flip - Beauty and Shopping  flip-beauty-shopping    1470077137  https://apps.apple.com/us/app/flip-beauty-shop...
7   Spin Live   spin-live   1519146498  https://apps.apple.com/us/app/spin-live/id1519...
1   Popshop - Live Shopping popshop-live-shopping   1009480270  https://apps.apple.com/us/app/popshop-live-sho...
5   Lalabox - Live Stream Shopping  lalabox-live-stream-shopping    1496718575  https://apps.apple.com/us/app/lalabox-live-str...
6   Supergreat Beauty   supergreat-beauty   1360338670  https://apps.apple.com/us/app/supergreat-beaut...
8   HERO®   hero-live-shopping  1178589357  https://apps.apple.com/us/app/hero-live-shoppi...
2   Whatnot: Buy, Sell, Gov Live    whatnot-buy-sell-go-live    1488269261  https://apps.apple.com/us/app/whatnot-buy-sell...
3   NTWRK - Live Video Shopping ntwrk-live-video-shopping   1425910407  https://apps.apple.com/us/app/ntwrk-live-video...
0   LIT Live - Live Shopping    lit-live-live-shopping  1507315272  https://apps.apple.com/us/app/lit-live-live-sh...


## Get list of app names and app IDs
app_names = list(app_df['iOS_app_name'])
app_ids = list(app_df['iOS_app_id'])```


## Set up App Store Scraper
scraper = AppStoreScraper()
app_store_list = list(scraper.get_multiple_app_details(app_ids))

## Pretty print the data for the first app
pprint(app_store_list[0])


https://itunes.apple.com/lookup?id=1507315272&country=nl&entity=software
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/opt/anaconda3/lib/python3.8/site-packages/itunes_app_scraper/scraper.py in get_app_details(self, app_id, country, lang, flatten)
    179                         result = json.loads(result)
--> 180                 except json.JSONDecodeError:
    181                         raise AppStoreException("Could not parse app store response")

IndexError: list index out of range

During handling of the above exception, another exception occurred:

AppStoreException                         Traceback (most recent call last)
<ipython-input-73-624146f96e92> in <module>
      1 ## Set up App Store Scraper
      2 scraper = AppStoreScraper()
----> 3 app_store_list = list(scraper.get_multiple_app_details(app_ids))
      4 
      5 app = result["results"][0]

/opt/anaconda3/lib/python3.8/site-packages/itunes_app_scraper/scraper.py in get_multiple_app_details(self, app_ids, country, lang)
    205                 :param str lang: Dummy argument for compatibility. Unused.
    206 
--> 207                 :return generator:  A list (via a generator) of app details
    208         """
    209                 for app_id in app_ids:

/opt/anaconda3/lib/python3.8/site-packages/itunes_app_scraper/scraper.py in get_app_details(self, app_id, country, lang, flatten)
    180                 except json.JSONDecodeError:
    181                         raise AppStoreException("Could not parse app store response")
--> 182 
    183                 try:
    184                         app = result["results"][0]

AppStoreException: No app found with ID 1507315272```

This is where I am stuck. It seems to be a simple problem but my experience is very limited. The url that App Store scraper use is not the same I used to retrieve app-ids from. Could this be the concern? Please help me to solve it. Thank you in advance!

标签: pythonweb-scraping

解决方案


推荐阅读