我正在编写一个小程序,每当在2021年11月之前出现道路测试预约时,我就会通知我。我刚开始学习Python,我在高中的一个编码课上有过java方面的经验。
问题是当我用
html_text = requests.get("https://www12.honolulu.gov/csdarts/frmApptInt.aspx").text
print(html_text)它打印出属于网站不同页面的数据(例如,我希望它显示koolau位置,而不是any位置)。
我想出了如何使到达页面的过程自动化,以及如何打印出https,但我很难将两者结合在一起。
这是我的第一篇文章,很抱歉,如果这是冗长或错误的。这是完整的代码-
from urllib.parse import urlunparse, urlparse
from urllib.request import urlretrieve
from selenium import webdriver
from bs4 import BeautifulSoup as bs
from urllib.request import ( urlopen, urlretrieve)
import os
import sys
import time
import requests
html_text =
requests.get("https://www12.honolulu.gov/csdarts/frmApptInt.aspx").text
print(html_text) soup = bs(html_text, 'lxml')
driver = webdriver.Chrome("C://webdrivers/chromedriver.exe")
driver.get("https://www12.honolulu.gov/csdarts/frmApptInt.aspx")
click_eligible = driver.find_element_by_xpath("/html/body/form/table/tbody/tr[2]/td/div[3]/input")
click_eligible.click()
click_location = driver.find_element_by_xpath("/html/body/form/table/tbody/tr[2]/td[1]/p[1]/table/tbody/tr/td/select")
click_location.click()
time.sleep(0.2)
click_koolau =
driver.find_element_by_xpath("//select/option[@value='6']")
click_koolau.click()
find = driver.find_element_by_xpath("/html/body/form/table/tbody/tr[2]/td[1]/p[1]/table/tbody/tr/td/input[1]")
find.click()发布于 2021-08-21 06:15:21
您应该能够执行这样的操作来获得源代码的html:
html = driver.page_sourcehttps://stackoverflow.com/questions/68870349
复制相似问题