2

I am trying to retrieve users reviews related information from google play store. I am interested in gathering reviewer name, reviewer text, reviewer rating and review date. I am using selenium webdriver for retrieving infromation. Here is my code:

baseurl='https://play.google.com/store/apps/details?id=com.zihua.android.mytracks&hl=en&showAllReviews=true'
driver.get(baseurl)

person_info = driver.find_elements_by_xpath("//div[@class='d15Mdf bAhLNe']")

for person in person_info:
    name = person.find_element_by_xpath("//span[@class='X43Kjb']").text
    review = person.find_element_by_xpath("//div[@class='UD7Dzf']/span").text
    print(name)
    print(review)

The problem with my code is it returns the first name of the reviewers and its review throughout the loop. Could anyone guide me where am I making the mistake?

1 Answer 1

4

It looks like you keep getting the same information again and again because each xpath-search starts from the beginning of the DOM. Something you can do is start your children-related xpaths with a '.' (dot) so as to only deal with children elements, as follows

for person in person_info:
    name = person.find_element_by_xpath(".//span[@class='X43Kjb']").text
    review = person.find_element_by_xpath(".//div[@class='UD7Dzf']/span").text
    print(name)
    print(review)
Sign up to request clarification or add additional context in comments.

2 Comments

Any question @u ? does it work ? I cannot test currently.
Wow. great. Didn't know about the dot operator. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.