Q:

scrapy: how to type argument in a blank space

I want to download the data from Yahoo Finance 
http://finance.yahoo.com/q/hp?s=^TWII&a=00&b=15&c=2004&d=11&e=4&f=2015&g=m
I want the program to type "2004" in the start year space and "2015" in the end year space. How can I do that? 
My codes look like this:
import scrapy
from selenium import webdriver
import time
from scrapy.selector import Selector
from scrapy.selector import HtmlXPathSelector
from taiex.items import taiexItem
import unicodecsv as csv

class taiex_spider(scrapy.Spider):
    name = 'taiex_spider'
    allowed_domains = ['finance.yahoo.com/']
    start_urls = ['http://finance.yahoo.com/q/hp?s=^TWII&a=00&b=15&c=2004&d=11&e=4&f=2015&g=m']

    def __init__(self):
        self.driver = webdriver.Firefox()

    def parse(self, response):
        items = []
        item = taiexItem()
        driver = self.driver
        driver.get(response.url)
        driver.find_element_by_css_selector('select[id="selstart"]>option[value="00"]').click() 
        driver.find_element_by_css_selector('select[id="selend"]>option[value="11"]').click()

        driver.find_element_by_xpath('//input[@id="monthly"]').click()
        driver.find_element_by_xpath('//input[@class="rapid-nf"]').click()
        driver.find_element_by_partial_link_text('Download to Spreadsheet').click()

A:

Locate the desired input elements by id and send the keys to them:
start_year = driver.find_element_by_id("startyear")
start_year.clear()
start_year.send_keys("2004")

end_year = driver.find_element_by_id("endyear")
end_year.clear()
end_year.send_keys("2015")

