import requests
import pandas as pd
from bs4 import BeautifulSoup
url = "https://appgrooves.com/app/kotak-811-and-mobile-banking-by-kotak-mahindra-bank-ltd/positive"
soup = BeautifulSoup(requests.get(url).content, 'lxml')
all_data = []
while True:
for r in soup.select('[id^="positive_mosthelpful_reviews"]'):
rating = r.select_one('.rating-stars')['class'][-1].split('-')[-1]
txt = r.select_one('[id^="review-item-body"]').get_text(strip=True)
all_data.append({'Review_Title': 'appgrooves reviews', 'URL': ' ',
'Review': txt, 'Stars': rating})
print(rating)
print(txt)
print('-' * 80)
btn = soup.select_one('button:contains("Show More Positive Reviews")')
if not btn:
break
data = requests.get('https://appgrooves.com' + btn['data-url-ajax'], headers = {'X-Requested-With': 'XMLHttpRequest'}).json()
soup = BeautifulSoup(data['data']['preview_html'], 'lxml')
df = pd.DataFrame(all_data)
print(df)
df.to_csv('data.csv')
Печатает:
Review_Title URL Review Stars
0 appgrooves reviews Kotak bank has nice app, I hold several intern... 5
1 appgrooves reviews Kotak bank has nice app, I hold several intern... 5
2 appgrooves reviews I love using this app for its easiness except ... 4
3 appgrooves reviews New update and Face ID login made the app go f... 4
4 appgrooves reviews This is the best mobile banking apps that I ha... 5
5 appgrooves reviews I have used many Indian as well as global bank... 5
6 appgrooves reviews Update: I have un-installed the app and reinst... 5
7 appgrooves reviews Love the Kotak app totally, simple to use inte... 5
8 appgrooves reviews Very user friendly and at the same time loaded... 5
9 appgrooves reviews 2 days back I received mandatory update and af... 5
10 appgrooves reviews Best user friendly banking mobile app. Intuiti... 5
11 appgrooves reviews App not working after latest update which has ... 5
12 appgrooves reviews Connecting credit card payment / net banking /... 5
13 appgrooves reviews Takes few seconds to make credit card payment.... 5
14 appgrooves reviews I I really trust this app - it has multiple la... 5
15 appgrooves reviews This so far has turned out to be the fastest a... 5
16 appgrooves reviews I updated to the latest version of Kotak app, ... 3
17 appgrooves reviews The app is too good and was working fine until... 4
и сохраняет data.csv
.