简体   繁体   中英

Python Web-scraping for Review

I need to scrape for the Review on the Nike Website.

I successfully extract the Class for the review but the Review itself is inside a.

My code is below:

*res = requests.get("https://www.nike.com/fr/t/polo-coupe-slim-polo-pour-kfhFZM/BQ4461-482")

soup = bs4.BeautifulSoup(res.text,'lxml')

product = soup.select(".review.mb10-sm")

for item in soup.select(".review.mb10-sm"): print(item.text)*

[Out]: **"Summer polo shirtA L. - 18 nov. 2020Great for wearing in the summer. I recommend it for the material and comfort.",

"Très bon produit.V I. - 25 juin 2020Rien à dire si ce n'est que je le recommande vivement"**

I want only the words "Great for wearing in the summer. I recommend it for the material and comfort." and "Great for wearing in the summer. I recommend it for the material and comfort.".

Please find below the screenshot for the html of the page.

enter image description here

You just need to go deeper in the css query, instead of

soup.select(".review.mb10-sm") 

change it to

soup.select(".review.mb10-sm div p") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM