{"id":18731,"date":"2022-11-01T19:25:00","date_gmt":"2022-11-01T13:55:00","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/"},"modified":"2022-11-01T19:25:00","modified_gmt":"2022-11-01T13:55:00","slug":"solved-how-to-scrape-all-product-review-from-lazada-in-python","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/","title":{"rendered":"[Solved] How to scrape all product review from lazada in python"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-59735223\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"59735223\" data-parentid=\"59734755\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>To do pagination use <code>infinite<\/code> while loop and #Check for <strong>button<\/strong> <code>next-pagination-item<\/code> have <code>**disable**<\/code> attribute then jump from loop else click on the next button.<\/p>\n<p><strong>Code<\/strong>:<\/p>\n<pre><code>from selenium import webdriver\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.webdriver.common.by import By\nimport time\n\ndriver=webdriver.Chrome(executable_path=\"chromedriver\")\ndriver.get(\"https:\/\/www.lazada.sg\/products\/loreal-paris-uv-perfect-even-complexion-sunscreen-spf50pa-30ml-i214861100-s325723972.html?spm=a2o42.seller.list.1.758953196tH2Mn&amp;mp=1\")\nreview_csv=[]\nproduct_csv = []\nrating_csv =[]\ndate_review_csv = []\ntitles = driver.find_element_by_class_name('pdp-mod-product-badge-title').text\nprint(titles)\nwhile True:\n      #Get the review details here\n      WebDriverWait(driver,10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR,\"div.item\")))\n      product_reviews = driver.find_elements_by_css_selector(\"[class=\"item\"]\")\n\n      # Get product review\n      for product in product_reviews:\n\n          review = product.find_element_by_css_selector(\"[class=\"content\"]\").text\n          if (review != \"\" or review.strip()):\n              print(review)\n              review_csv.append(review)\n          else:\n              print(review)\n              review_csv.append(\"No comments\/review is an image\")\n\n          # Product Purchase\n          # Check if the product purchase exists\n\n          product_purchase = product.find_element_by_css_selector(\"[class=\"skuInfo\"]\").text\n          print(product_purchase)\n          product_csv.append(product_purchase)\n\n          # Star rating\n          star_ratings = product.find_elements_by_css_selector(\"[class=\"star\"]\")\n          stars = \"https:\/\/laz-img-cdn.alicdn.com\/tfs\/TB19ZvEgfDH8KJjy1XcXXcpdXXa-64-64.png\"\n\n          star_rate = 0\n          for rating in star_ratings:\n              # print(rating.get_attribute('src'))\n              if (rating.get_attribute('src') == stars):\n                  star_rate = star_rate + 1\n          rating_csv.append(star_rate)\n          print(star_rate)\n\n          # Date of Review\n          date = product.find_element_by_css_selector(\"[class=\"title right\"]\").text\n          date_review_csv.append(date)\n          print(date)\n\n      #Check for button next-pagination-item have disable attribute then jump from loop else click on the next button\n      if len(driver.find_elements_by_css_selector(\"button.next-pagination-item.next[disabled]\"))&gt;0:\n          break;\n      else:\n          button_next=WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, \"button.next-pagination-item.next\")))\n          driver.execute_script(\"arguments[0].click();\", button_next)\n          print(\"next page\")\n          time.sleep(2)\ndriver.close()\nprint(review_csv)\nprint(product_csv)\nprint(rating_csv)\nprint(date_review_csv)\n<\/code><\/pre>\n<hr>\n<p><strong>List printed like:<\/strong><\/p>\n<pre><code>['Fast delivery, send within 3 days, in bubble envelope. Product expiry date : 0522', 'received in good condition. have not try it yet', 'No comments\/review is an image', 'No comments\/review is an image', 'No comments\/review is an image', 'No comments\/review is an image', 'No comments\/review is an image', 'No comments\/review is an image']\n<\/code><\/pre>\n<hr>\n<pre><code>['Volume (ml):30', 'Volume (ml):30', 'Volume (ml):30', 'Volume (ml):30', 'Volume (ml):30', 'Volume (ml):30', 'Volume (ml):30', 'Volume (ml):30']\n<\/code><\/pre>\n<hr>\n<pre><code>[5, 5, 5, 4, 4, 5, 5, 5]\n<\/code><\/pre>\n<hr>\n<pre><code>['24 Oct 2019', '17 Nov 2019', '21 Nov 2019', '25 Oct 2019', '29 Aug 2019', '24 Apr 2019', '19 Jan 2019', '11 Nov 2018']\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">2<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How to scrape all product review from lazada in python <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] To do pagination use infinite while loop and #Check for button next-pagination-item have **disable** attribute then jump from loop else click on the next button. Code: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import time driver=webdriver.Chrome(executable_path=&#8221;chromedriver&#8221;) driver.get(&#8220;https:\/\/www.lazada.sg\/products\/loreal-paris-uv-perfect-even-complexion-sunscreen-spf50pa-30ml-i214861100-s325723972.html?spm=a2o42.seller.list.1.758953196tH2Mn&amp;mp=1&#8221;) review_csv=[] product_csv = [] rating_csv =[] &#8230; <a title=\"[Solved] How to scrape all product review from lazada in python\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\" aria-label=\"More on [Solved] How to scrape all product review from lazada in python\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[349,611,760],"class_list":["post-18731","post","type-post","status-publish","format-standard","hentry","category-solved","tag-python","tag-selenium","tag-web-scraping"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How to scrape all product review from lazada in python - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How to scrape all product review from lazada in python - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] To do pagination use infinite while loop and #Check for button next-pagination-item have **disable** attribute then jump from loop else click on the next button. Code: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import time driver=webdriver.Chrome(executable_path=&quot;chromedriver&quot;) driver.get(&quot;https:\/\/www.lazada.sg\/products\/loreal-paris-uv-perfect-even-complexion-sunscreen-spf50pa-30ml-i214861100-s325723972.html?spm=a2o42.seller.list.1.758953196tH2Mn&amp;mp=1&quot;) review_csv=[] product_csv = [] rating_csv =[] ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-01T13:55:00+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How to scrape all product review from lazada in python\",\"datePublished\":\"2022-11-01T13:55:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\"},\"wordCount\":50,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"python\",\"selenium\",\"web-scraping\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\",\"name\":\"[Solved] How to scrape all product review from lazada in python - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-11-01T13:55:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How to scrape all product review from lazada in python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How to scrape all product review from lazada in python - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How to scrape all product review from lazada in python - JassWeb","og_description":"[ad_1] To do pagination use infinite while loop and #Check for button next-pagination-item have **disable** attribute then jump from loop else click on the next button. Code: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import time driver=webdriver.Chrome(executable_path=\"chromedriver\") driver.get(\"https:\/\/www.lazada.sg\/products\/loreal-paris-uv-perfect-even-complexion-sunscreen-spf50pa-30ml-i214861100-s325723972.html?spm=a2o42.seller.list.1.758953196tH2Mn&amp;mp=1\") review_csv=[] product_csv = [] rating_csv =[] ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/","og_site_name":"JassWeb","article_published_time":"2022-11-01T13:55:00+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How to scrape all product review from lazada in python","datePublished":"2022-11-01T13:55:00+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/"},"wordCount":50,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["python","selenium","web-scraping"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/","name":"[Solved] How to scrape all product review from lazada in python - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-11-01T13:55:00+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-scrape-all-product-review-from-lazada-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How to scrape all product review from lazada in python"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/18731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=18731"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/18731\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=18731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=18731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=18731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}