I would like to scrape all exhibitor names and information from this link: https://asiatechxsg.com/exhibitors/ into a csv file.
So far, I have:
exhibitor_names = []
exhibitor_info = []
exhibitor_web = []
exhibitor_linkedin = []
exhibitor_twitter = []
exhibitor_email = []
exhibitor_contact = []
exhibitor_booth = []
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://asiatechxsg.com/exhibitors/")
wait = WebDriverWait(driver, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CLASS_NAME, "IframeModule_iframe__JCvXg")))
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
match=False
while(match==False):
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
last_element = driver.find_elements(By.XPATH, "//img[@alt='Singapore Centre for Social Enterprise, raiSE Ltd']")
if (len(last_element) >= 1):
match=True
# Get names
names = wait.until(EC.visibility_of_all_elements_located((By.XPATH, "//span[@class='sc-a13c392f-0 sc-85df61db-4 feepZZ eErKol']")))
print("No. of sponsors and exhibitors= " + str(len(names)))
for name in names:
exhibitor_names.append(name.text)
# Get info
link_xpath = "//a[contains(@href, '/widget/event/asia-tech-x-singapore-2024/exhibitor/')]"
link_element = wait.until(EC.element_to_be_clickable((By.XPATH, link_xpath)))
link_element.click()
info_div = wait.until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@class='sc-8cd680a3-0 lbArDv']")))
paragraphs = info_div.find_elements(By.TAG_NAME, "p")
info = 'n'.join([p.text for p in paragraphs])
exhibitor_info.append(info)
The get names part works fine. The problem comes when I try to get everything else (to fill up the initialised empty lists). I need to click in to see the rest of the things. I’m new to selenium..I don’t really know if what I’m doing is right. It doesn’t work so obviously I’m doing something wrong. I just don’t know what. Please help. Thank you in advance
user22279494 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.