1

I used the following code to scrape the reviews from AliExpress. However, I want to scrape the content as it appears in the Arabic URL. I used the Arabic URL in the code, but it shows the reviews in English even if they are not originally in English which means it shows the reviews after translating them into English.

from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd

url = 'https://ar.aliexpress.com/item/1005003801507855.html?spm=a2g0o.productlist.0.0.1e951bc72xISfE&algo_pvid=6d3ed61e-f378-43d0-a429-5f6cddf3d6ad&algo_exp_id=6d3ed61e-f378-43d0-a429-5f6cddf3d6ad-8&pdp_ext_f=%7B%22sku_id%22%3A%2212000027213624098%22%7D&pdp_pi=-1%3B40.81%3B-1%3B-1%40salePrice%3BMAD%3Bsearch-mainSearch&gatewayAdapt=glo2ara'

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get(url)

wait = WebDriverWait(driver, 10)

driver.execute_script("arguments[0].scrollIntoView();", wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.tab-content'))))
driver.get(wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '#product-evaluation'))).get_attribute('src'))

data=[]

while True:

    for e in driver.find_elements(By.CSS_SELECTOR, 'div.feedback-item'):

        try:
            country = e.find_element(By.CSS_SELECTOR, '.user-country > b').text
        except:
            country = None

        try:
            comment = e.find_element(By.CSS_SELECTOR, '.buyer-feedback span').text
            print(comment)
        except:
            comment = None

        data.append({
            'country':country,
            'comment':comment
        })
    try:
        wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '#complex-pager a.ui-pagination-next'))).click()
    except:
        break

pd.DataFrame(data).to_csv('filename.csv',index=False)

Output:

they actually work pretty good! i mean, there's practically negative-50 on bass, but they work good, hold good charge, and are super simple. they don't akwayd connect on the spot though, so you might have to put it back in and pull it out once or twice to connect but they work great when I REALLY need to have music and my big bass headphones are dead! I love them other than the lack of bass I like the product for the price Is okay I never received this I bought 3,and 1 the display dies not work for battery charging.... awful sounding head phones Very good Very good article The package I get but my bad audio quality it has, one is heard more than another and it does not have very good sound, it looks nice but it does not serve excelente Very good article Was not accurate Good item

I tried to find the checkbox that is responsible for showing the translated reviews and click it using the code below. It shows the original reviews in their different languages.

driver.execute_script("arguments[0].scrollIntoView();", wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.tab-content'))))
driver.get(wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '#product-evaluation'))).get_attribute('src'))

Output:

they actually work pretty good! i mean, there's practically negative-50 on bass, but they work good, hold good charge, and are super simple. they don't akwayd connect on the spot though, so you might have to put it back in and pull it out once or twice to connect but they work great when I REALLY need to have music and my big bass headphones are dead! I love them other than the lack of bass I like the product for the price está bien I never received this I bought 3,and 1 the display dies not work for battery charging.... awful sounding head phones muy buenos Muy buen artículo El paquete me llego pero miy mala calidad de audio que tiene, se oye uno mas que otro y no tiene muy buen sonido, se ve bonito pero no sirbe excelente Muy buen articulo no fue exacto Buen artículo

I want now to extract the reviews after translating them into Arabic, how can I do that?

Reem
  • 107
  • 1
  • 7

0 Answers0