Python Forum

Full Version: Scrape java script web site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I just want scrap java script web site.
url : https://www.mcxindia.com/market-data/bhavcopy
Can anyone help me on this.

Thanks in advance
what have you tried so far?
please show code
Hello PythonHunger,
Can you provide the code so that we can get a clarity and maybe a chance to help you?
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]
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
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.
First of all 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.
Hi metulburr.
Its working fine now.
Thank you very much for the reply Smile .
Thanks you sir Smile