Oct-24-2018, 05:01 AM
Oct-24-2018, 06:24 AM
what have you tried so far?
please show code
please show code
Oct-24-2018, 08:37 AM
Hello PythonHunger,
Can you provide the code so that we can get a clarity and maybe a chance to help you?
Can you provide the code so that we can get a clarity and maybe a chance to help you?
Oct-24-2018, 09:11 AM
Hi,
Thanks for the reply.
I just want to download csv/excel file from url https://www.mcxindia.com/market-data/bhavcopy .
![[Image: excel.png]](https://www.mcxindia.com/Includes/images/excel.png)
I have write a code but got error and browser not getting close.
Thanks for the reply.
I just want to download csv/excel file from url https://www.mcxindia.com/market-data/bhavcopy .
![[Image: excel.png]](https://www.mcxindia.com/Includes/images/excel.png)
I have write a code but got error and browser not getting close.
from selenium import webdriver chrome_options = webdriver.ChromeOptions() path_to_chromedriver = 'D:\ChromeDriver\chromedriver.exe' browser = webdriver.Chrome(executable_path=path_to_chromedriver, options=chrome_options) url = 'https://www.mcxindia.com/market-data/bhavcopy' browser.get(url) f = open(browser.find_element_by_id('cph_InnerContainerRight_C001_lnkExpToCSV').click(), 'wb') browser.quit()getting error :
Error:TypeError: expected str, bytes or os.PathLike object, not NoneType
Oct-24-2018, 03:48 PM
The error you show doesn't look like the complete error traceback. Please post verbatim as it contains valuable information.
Quote:I just want to download csv/excel file from url url:https://www.mcxindia.com/market-data/bhavcopy .you don't need selenium for this, you can get it with a simple requests statement:
import requests excelfile = resquests.get(url)Also, I tried to connect to that server and timed out.
Oct-24-2018, 07:57 PM
First of all
you dont have to use open() at all. You only have to click the button and it should download. However you might want to wait a few seconds after the click to allow it to download.
find_element_by_id
returns None. And you cannot set the filename to None. Second of all...you dont have to use open() at all. You only have to click the button and it should download. However you might want to wait a few seconds after the click to allow it to download.
browser.find_element_by_id('cph_InnerContainerRight_C001_lnkExpToCSV').click() time.sleep(10)Just tested with this ant it works fine.
Oct-25-2018, 05:59 AM
Hi metulburr.
Its working fine now.
Thank you very much for the reply
.
Thanks you sir
Its working fine now.
Thank you very much for the reply

Thanks you sir
