-1

I would like to use a tool from the command line to fetch the file that can be manually downloaded by clicking on the Export to Excel link present in the following page on the right.

https://www.hkex.com.hk/Market-Data/Securities-Prices/Equities/Equities-Quote?sym=700&sc_lang=en

I tried a few simply tools like wget or curl for this purpose, but with no luck because the url is masked. Can you suggest any tool that would do the job?

Thanks ìn advance.

Stephan
  • 53,940
  • 10
  • 58
  • 91
Arturo
  • 342
  • 1
  • 4
  • 14

1 Answers1

1

Using Selenium you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using LINK_TEXT:

    driver.get("https://www.hkex.com.hk/Market-Data/Securities-Prices/Equities/Equities-Quote?sym=700&sc_lang=en")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Export to Excel"))).click()
    
  • Browser Snapshot:

download

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Works great! Thank you so much. I have just a quick question. Would it be possible to save the file directly to disk (no prompt) without messing up with the firefox settings? – Arturo Nov 24 '21 at 13:17
  • @Arturo I have tested the code and as of now it does just like that, no additional firefox settings required. – undetected Selenium Nov 24 '21 at 13:18
  • I guess you have already set in firefox how to handle this file type. Anyway, thank again for your help and assistance- – Arturo Nov 24 '21 at 13:35
  • Ahh, I tested it on Chrome. If you are using a `FirefoxProfile` check this [discussion](https://stackoverflow.com/questions/44072022/python-unable-to-download-with-selenium-in-webpage/44196146#44196146) – undetected Selenium Nov 24 '21 at 13:38