Need assistance to complete the rest tasks:
- Click and open the link under "SUMMARY"
- Copy the new html link to a variable for future use.
- Download the pdf into a folder
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Firefox(executable_path = "C:\Program Files\Mozilla Firefox\geckodriver.exe")
driver.maximize_window()
driver.implicitly_wait(30)
driver.get("https://www1.hkexnews.hk/search/titlesearch.xhtml")
wait = WebDriverWait(driver, 20)
StockList = ['02192']
wait.until(EC.element_to_be_clickable((By.ID, "searchStockCode"))).send_keys(StockList[0])
wait.until(EC.element_to_be_clickable((By.ID, "searchTitle"))).send_keys( "Announcement of Offer Price and Allotment Results" )
ele = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@class='slimScrollDiv']/descendant::tbody/tr[1]")))
ActionChains(driver).move_to_element(ele).click().perform()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[class*='applyFilters']"))).click()
driver.find_element_by_link_text("Announcement of Offer Price and Allotment Results").click()