我正在为一个项目创建一个网络爬虫。下面脚本的输出将放入SQL数据库。我想知道的是,如何将第26行的列表索引更改为9
from selenium import webdriver as wd
from selenium.webdriver.chrome.options
import Options as Op
import csv
import mysql.connector
url = ['https://craz.ca/monitoring/calgary-central/', 'https://craz.ca/monitoring/calgary-
southeast/', 'https://craz.ca/monitoring/calgary-northwest/']
def ce():
urlce = url[0]
ce_options = Op()
#Add arguments here - if the server runs on windows
#and here if the serve runs on linux
#and here - if you want to not open a chrome window
ce_driver = wd.Chrome(options=ce_options)
ce_driver.get(urlce)
jsv_ce = ce_driver.find_element_by_link_text("Tabular Data")
jsv_ce.click()
#this is the list
ce_data = ce_driver.find_elements_by_xpath("""//*[@id="tableDisplay"]/table/tbody/tr/td""")
for i in ce_data:
#x = 9
#dtime = 0
#dtime += x
print(ce_data[27].text)
ce()
我正在抓取的网站上的表有一个表,其中有九列。网站URL位于此处:CRAZ
目前没有回答
相关问题 更多 >
编程相关推荐