【Python爬⾍】IOS苹果商店指定APP评论爬取
import requests
import json
import time
import random
import pandas as pd
from random import randint
app_id='1288515333'
### 设置部分
# app_id='1419975581'  # 设置app的id
qt教程
reviews_count=450# 设置采集的数量
### 采集部分
all_list=[]
for page_num in range(10000000):
offset=page_num*10
java课程设计案例源码
if offset>=reviews_count:
break
print('*'*60)
print('已采集{}个'.format(offset+10))
api='amp-api.apps.apple/v1/catalog/cn/apps/{}/reviews?l=zh-Hans-CN&offset={}&platform=web&additionalPlatforms=appletv%2Cipad%2Ciph one%2Cmac'.format(app_id,offset)
headers={
爬虫软件 app
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
'authorization':'Jpc3MiOiI3TktaMlZQNDhaIiwiaWF0IjoxNjEzMTY5M zg0LCJleHAiOjE2MTYxOTMzODR9.AyRdwIabKUIAOzUjwhw4tdWdfj4BSkUxpctFNg19A87VmOe1iplzpvcKlIJhb5mfOwi27UdVfDCRzSn6iT8PoA' # Jpc3MiOiI3TktaMlZQNDhaIiwiaWF0IjoxNjEzMTY5Mzg0LCJleHAi OjE2MTYxOTMzODR9.AyRdwIabKUIAOzUjwhw4tdWdfj4BSkUxpctFNg19A87VmOe1iplzpvcKlIJhb5mfOwi27UdVfDCRzSn6iT8PoA
反函数怎么求极限
}
while True:
try:
while True:
try:
(url=api,headers=headers)
break
ptions.ConnectTimeout:
time.sleep(randint(1,3))
continue
ptions.ReadTimeout:
security证书没啥用
time.sleep(randint(1,3))
continue
ptions.ConnectionError:
time.sleep(randint(1,3))
continue
ptions.ChunkedEncodingError:
time.sleep(randint(1,3))
continue
json=response.json()
info_list=json['data']
break
except KeyError:
time.sleep(2)
continue
for info in info_list:
# print(info)
rating=info['attributes']['rating']
跟java类似的语言
title=info['attributes']['title']
date=info['attributes']['date']
date=info['attributes']['date']
review=info['attributes']['review']
info=[rating,title,date,review]
all_list.append(info)
time.sleep(1)
columns=['评分','标题','⽇期','评论']
df=pd.DataFrame(data=all_list,columns=columns)
<_csv(r'C:\Users\kww\Desktop\移动端爬取\{}.csv'.format(app_id),index=False)结果展⽰:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。