<jupyter_start><jupyter_text>scraping ratings and reviews of laptops<jupyter_code>URL=[]
for j in range(0,147):
    review_tags=driver.find_elements_by_xpath("//nav[@class='yFHi8N']")
    for i in review_tags:
        review_tags1=i.find_element_by_tag_name("a")
        URL.append(review_tags1.get_attribute('href'))
        
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
        time.sleep(3)
URL
len(URL)
List_of_url = []
for i in URL:
    if i not in List_of_url:
        List_of_url.append(i)
len(List_of_url)
List_of_url
#going to the first url through our driver
driver.get(List_of_url[0])
#running a loop to extract all the required information from url
Ratings=[]
Full_review=[]
from tqdm import tqdm
for i in tqdm(List_of_url):
    driver.get(i)
    
    
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
Ratings
Full_review
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/apple-macbook-air-core-i5-5th-gen-8-gb-128-gb-ssd-mac-os-sierra-mqd32hn-a/product-reviews/itm0602f520428ca?pid=COMEVCPQBXBDFJ8C&lid=LSTCOMEVCPQBXBDFJ8C4V6AHG&marketplace=FLIPKART'
#opening the webpage through our driver
driver.get(url)
for i in range(0,328): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
    driver.execute_script("arguments[0].click();", button)
    
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/asus-celeron-dual-core-4-gb-1-tb-hdd-windows-10-home-x543ma-gq1015t-laptop/product-reviews/itmf8811674edbeb?pid=COMFSKF9UQH8RKYF&lid=LSTCOMFSKF9UQH8RKYFK8UKIL&marketplace=FLIPKART'
#opening the webpage through our driver
driver.get(url)
for i in range(0,97): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/lenovo-ideapad-s145-ryzen-3-dual-core-3200u-4-gb-1-tb-hdd-windows-10-home-s145-15api-thin-light-laptop/product-reviews/itm3028b196c8fe1?pid=COMFJM3T7ZF2Z86F&lid=LSTCOMFJM3T7ZF2Z86FUWBWK9&marketplace=FLIPKART'
#opening the webpage through our driver
driver.get(url)
for i in range(0,73): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of mobile phones<jupyter_code>url='https://www.flipkart.com/redmi-9-power-electric-green-64-gb/product-reviews/itmca7d78e222ed7?pid=MOBFYZ7AVAXXB2TH&lid=LSTMOBFYZ7AVAXXB2THVSNL0U&marketplace=FLIPKART'
driver.get(url)
for i in range(0,367): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/motorola-g30-dark-pearl-64-gb/product-reviews/itme5ae7fa01f345?pid=MOBFVXGZWDHJHQGZ&lid=LSTMOBFVXGZWDHJHQGZBI5YJU&marketplace=FLIPKART'
driver.get(url)
for i in range(0,157): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/motorola-e7-plus-misty-blue-64-gb/product-reviews/itm9a59be77f1cd2?pid=MOBFTYWW8QWUYDZU&lid=LSTMOBFTYWW8QWUYDZUM6DQNI&marketplace=FLIPKART'
driver.get(url)
for i in range(0,373): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of headphones<jupyter_code>url='https://www.flipkart.com/mivi-collar-classic-fast-charging-bluetooth-headset/product-reviews/itmd6a3a8e12473f?pid=ACCGFGJTGWRHZUAF&lid=LSTACCGFGJTGWRHZUAF3XZAXJ&marketplace=FLIPKART'
driver.get(url)
for i in range(0,216): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/ubon-ub-770-wired-headset/product-reviews/itmc75e7cc4986df?pid=ACCFHCAPHTPCCXZR&lid=LSTACCFHCAPHTPCCXZRKLYRFC&marketplace=FLIPKART'
driver.get(url)
for i in range(0,234): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of smart watches<jupyter_code>url='https://www.flipkart.com/alonzo-dz09-new-phone-smartwatch/product-reviews/itm44bd98f3bf1e7?pid=SMWF5BFJHTDYCYYD&lid=LSTSMWF5BFJHTDYCYYDJIL5XV&marketplace=FLIPKART'
driver.get(url)
for i in range(0,106): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/life-like-v8-bluetooth-sim-tf-card-slot-smartwatch/product-reviews/itm8deac9de357e6?pid=SMWEQJPTGWKCBDUD&lid=LSTSMWEQJPTGWKCBDUDPTTYUT&marketplace=FLIPKART'
driver.get(url)
for i in range(0,51): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/fitbit-versa-special-smartwatch/product-reviews/itme0fd47f890e7f?pid=SMWFDYBW3829GKEY&lid=LSTSMWFDYBW3829GKEY8DNWTD&marketplace=FLIPKART'
driver.get(url)
for i in range(0,39): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of professional cameras<jupyter_code>url='https://www.flipkart.com/canon-eos-3000d-dslr-camera-1-body-18-55-mm-lens-battery-battery-charger-usb-cable/product-reviews/itmed1b57035d2fc?pid=CAMF3DHJURPEMNRN&lid=LSTCAMF3DHJURPEMNRNYD4BKP&marketplace=FLIPKART'
driver.get(url)
for i in range(0,330): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/nikon-d5600-dslr-camera-body-dual-lens-af-p-dx-nikkor-18-55-mm-f-3-5-5-6g-vr-70-300-f-4-5-6-3g-ed/product-reviews/itm8bd75efa91403?pid=DLLEZVB8MDXDYTHG&lid=LSTDLLEZVB8MDXDYTHGP8CUFI&marketplace=FLIPKART'
driver.get(url)
for i in range(0,169): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of printers<jupyter_code>url='https://www.flipkart.com/canon-pixma-mg2470-all-in-one-inkjet-printer/product-reviews/itmdqatqsyzyzffn?pid=PRNDQAR9KZEKSKRF&lid=LSTPRNDQAR9KZEKSKRFEMB7B0&marketplace=FLIPKART'
driver.get(url)
for i in range(0,610): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/hp-deskjet-2331-multi-function-color-printer/product-reviews/itm5708dbe303a73?pid=PRNFTXAWZ9DZ2KHR&lid=LSTPRNFTXAWZ9DZ2KHRP7ZAXV&marketplace=FLIPKART'
driver.get(url)
for i in range(0,52): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of monitors<jupyter_code>url='https://www.flipkart.com/dell-18-5-inch-hd-led-backlit-tn-panel-monitor-d1918h/product-reviews/itmewm8z6awyx9rr?pid=MONEWM8ZKY38PWVP&lid=LSTMONEWM8ZKY38PWVPIKWEMH&marketplace=FLIPKART'
driver.get(url)
for i in range(0,58): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/hp-23-8-inch-full-hd-led-backlit-ips-panel-monitor-24es/product-reviews/itm5613f46e3d8db?pid=MONEQFE5PQNQHHZF&lid=LSTMONEQFE5PQNQHHZFESEDRU&marketplace=FLIPKART'
driver.get(url)
for i in range(0,39): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of home theaters<jupyter_code>url='https://www.flipkart.com/intex-it-2616-bt-55-w-bluetooth-home-theatre/product-reviews/itm835ba2477ca67?pid=ACCFNMEYJNHSNCWN&lid=LSTACCFNMEYJNHSNCWNXWFCRW&marketplace=FLIPKART'
driver.get(url)
for i in range(0,216): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/intex-2622-portable-bluetooth-home-theatre/product-reviews/itmd7aeef0b49f57?pid=ACCEPBDW89GY8ZYU&lid=LSTACCEPBDW89GY8ZYUZCVLEQ&marketplace=FLIPKART'
driver.get(url)
for i in range(0,134): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)<jupyter_output><empty_output><jupyter_text>scraping ratings and reviews of routers<jupyter_code>url='https://www.flipkart.com/mi-r4cm-300-mbps-router/product-reviews/itm4ed0ab10f43e5?pid=RTRFZ9XMNKDBSHCY&lid=LSTRTRFZ9XMNKDBSHCY2N0IPP&marketplace=FLIPKART'
driver.get(url)
for i in range(0,143): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
len(Ratings)
len(Full_review)
url='https://www.flipkart.com/tenda-n301-300-mbps-router/product-reviews/itmehkf7am7tpawg?pid=RTRDYEYZKF884XRZ&lid=LSTRTRDYEYZKF884XRZA1WPYP&marketplace=FLIPKART'
driver.get(url)
for i in range(0,162): 
    for j in driver.find_elements_by_xpath("//div[@class='_3LWZlK _1BLPMq' or @class='_3LWZlK _32lA32 _1BLPMq' or @class='_3LWZlK _1rdVr6 _1BLPMq']"):
        Ratings.append(j.text)
            
            
    for k in driver.find_elements_by_xpath("//div[@class='t-ZTKy']/div/div"):
        Full_review.append(k.text.replace('\n',' '))
    
    try:
        button=driver.find_element_by_xpath("//*[contains(text(), 'Next')]")
        driver.execute_script("arguments[0].click();", button)
    except NoSuchElementException:
        pass
    time.sleep(2)
#printing lengths
print(len(Ratings),len(Full_review))
#creating a dataframe
Reviews=pd.DataFrame({})
Reviews['Ratings']=Ratings
Reviews['Full_review']=Full_review
Reviews
#converting into csv format
Reviews.to_csv("Reviews.csv")
#closing the driver
driver.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15261538461538462, 'fraction_numerical': 0.03784615384615385, 'mean_word_length': 4.082356007297368, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 21, 'lorem ipsum': 0, 'www.': 21, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '404432', 'license': 'MIT', 'n_tokens_mistral': 8363, 'n_tokens_neox': 7985, 'n_words': 914, 'path': 'Web scraping rating and reviews.ipynb', 'repo_name': 'Abhi1601/Ratings-Prediction-Project', 'size': '19500'}