I was building a web scraper by using python selenium
. The script scraped sites like amazon, stack overflow and flipcart but wasn't able to scrape ofashion. It is always returning me a blank .csv file.
Here is my code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import pandas as pd
import timeuser_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) ' \'Chrome/80.0.3987.132 Safari/537.36'driver_exe = 'chromedriver'
options = Options()
#options.add_argument("--headless")
options.add_argument(f'user-agent={user_agent}')
options.add_argument("--disable-web-security")
options.add_argument("--allow-running-insecure-content")
options.add_argument("--allow-cross-origin-auth-prompt")driver = webdriver.Chrome(executable_path=r"C:\Users\intel\Downloads\Setups\chromedriver.exe", options=options)
driver.get("https://www.ofashion.com.cn/goods/10001?t=15777838840003")
class_Name = "." + "ellipsis-single ware-brand"
x = driver.find_elements_by_css_selector(class_Name.replace(' ','.'))
web_content_list = []for i in x:web_content_dict = {}web_content_dict["Title"] = i.textweb_content_list.append(web_content_dict)df = pd.DataFrame(web_content_list)
df.to_csv(r'C:\Users\intel\Desktop\data_file.csv',index=False, mode='a', encoding='utf-8')
Any help would be appreciated!