【发布时间】:2021-08-27 09:50:49
【问题描述】:
我试试代码
allSpanDate = self.driver.find_element_by_xpath("//span[text()='08/28']").click()
但只有第一个元素被点击
所以我这样编辑但不会工作
allSpanDate = self.driver.find_element_by_xpath("//span[text()='08/28']")
for spanDate in allSpanDate:
spanDate.click()
网站是
http://211.21.63.217:81/ticket_online.aspx
如何点击所有跨度文本是 08/28 ?
from selenium import webdriver
class CenturyasiaxinbeiSpider(scrapy.Spider):
name = 'CenturyasiaXinbei'
allowed_domains = ['www.centuryasia.com.tw', '211.21.63.217:81']
start_urls = ['http://211.21.63.217:81/ticket_online.aspx']
def __init__(self):
print('__init__')
self.driver = webdriver.Chrome('/Users/motogod19/chromedriver')
self.driver.get('http://211.21.63.217:81/ticket_online.aspx')
def parse(self, response):
allSpanDate = self.driver.find_element_by_xpath("//span[text()='08/28']")
for spanDate in allSpanDate:
spanDate.click()
time.sleep(10)
【问题讨论】: