我正在用Python自动化网络爬虫
这是我的代码
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Edge(r"C:\Users\siddhi.tharval\Downloads\edgedriver_win64 (1).exe")
driver.get('https://www.makemytrip.com/flights/')
driver.maximize_window()
#to choose round trip
round_trip = driver.find_element(By.XPATH,'//*[@id="top-banner"]/div[2]/div/div/div/div[1]/ul/li[2]')
round_trip.click()
time.sleep(4)
#From city
fromcity = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, 'fromCity'))).click()
#from city input box
fromfield=driver.find_element(By.XPATH, "//input[@placeholder='From']")
fromfield.send_keys(dep_city)
#dropdown first suggestion
firstsuggestion= driver.find_element(By.XPATH, '//*[@id="react-autowhatever-1-section-0-item-0"]')
firstsuggestion.click()
#tocity
tocity= WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, 'toCity'))).click()
#tocity input box
tofield= driver.find_element(By.XPATH, "//input[@placeholder='To']")
tofield.send_keys(des_city)
#dropdown first suggestion
sugges=driver.find_element(By.XPATH, '//*[@id="react-autowhatever-1-section-0-item-0"]').click()
time.sleep(10)
#start date
startdate = driver.find_element(By.XPATH, "//div[@class='DayPicker-Day'][2]").click()
time.sleep(10)
#end date
enddate = driver.find_element(By.XPATH, "//div[@class='DayPicker-Day'][3]").click()
#From
search= WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//a[contains(@class,"widgetSearchBtn")]'))).click()
请帮我解决这个问题,我希望在我的webdriver上能打开航班页面,而不是出现这个网络错误。在webdriver网站上点击搜索按钮后,航班列表页面没有打开,而是显示了我分享的错误的网络问题。
0 个回答
暂无回答