0

I would like to scrape all the annual financial reports from 2016-03-01 to 2017-02-28 of the listed companies in Shanghai Stock Exchange.

http://www.sse.com.cn/disclosure/listedinfo/regular/

While the search is a hidden javascript, I am not sure how to input the date. Please help.

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
import bs4
from bs4 import BeautifulSoup
import urllib.request

url = "http://www.sse.com.cn/disclosure/listedinfo/regular/"

chrome_path = r"/chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get(url)

start_date = "2016-03-01"
end_date = "2017-02-28"
start = driver.find_element_by_id("start_date")
end = driver.find_element_by_id("end_date")
search = driver.find_element_by_id("btnQuery")

actions = ActionChains(driver)
actions.send_keys_to_element(start, start_date)      #can't send key
actions.send_keys_to_element(end, end_date)          #can't send key
actions.click(search)
actions.perform()
ou_ryperd
  • 2,037
  • 2
  • 18
  • 23
Jessica
  • 11
  • 3
  • Related - https://stackoverflow.com/questions/39520708/using-selenium-on-calendar-date-picker – shad0w_wa1k3r Apr 02 '17 at 10:43
  • @Ashish Nitin Patil Thanks. But it seems that the case in this related question has text field to input the dates. My case has date picker only but no text field. – Jessica Apr 02 '17 at 11:22
  • The field might be hidden. The form will always need the field. If the js is instead constructing a url for a simple GET request, then the solution is much simpler. – shad0w_wa1k3r Apr 02 '17 at 11:35

0 Answers0