我正在尝试从网站执行搜索/过滤后从网络表中提取数据。我有问题包围我如何执行搜索然后刮。下面我添加了请求表单中的HTML以及我到目前为止的代码。我尝试了多种方法,但都失败了。最后,我想将结果表中的数据拉入.csv。
<table title="Search Results" id="searchResults" class="defaultGrid" summary="Search results based on search criteria"
<a href="#" id="docSearchButton">Search</a>
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from selenium.webdriver.support import expected_conditions as EC
import urllib
import requests
import csv
import pandas as pd
#here is where I wrote the search automation; Need to figure out how to combine above
driver = webdriver.Firefox()
driver.get("httph:")
driver.maximize_window()
#driver.find_element_by_xpath("//*[@id="districtDROPDOWN"]").send_keys(01)
dropdown = driver.find_element_by_xpath("//*[@id='districtDROPDOWN']")
select = Select(dropdown)
select.select_by_value("01")
driver.find_element_by_xpath("//*[@id='docSearchButton']").click()
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)
#scraper starts here
finally:
#finally I have no clue what to do here; StackOverflow it is