我正在尝试在数据库中搜索公司名称,然后使用Selenium下载公司记录。问题是当我搜索公司时,有时会有多个相似的结果/公司,因此我无法编写Selenium来每次都静态地选择相同的事物。如何确定所有结果,然后选择“最相似”选项。
例如,如果我搜索实体“ Bowman Real Estate LLC”,浏览器将在表中返回三个结果,即“ Bowman Real Estate LLC”,“ Bowman Real Estate and Development LLC”和“ Bowman Real Estate&Development Group” LLC”
我需要能够识别页面源代码中的所有选项,然后确定最相似的选项,然后单击它以前进至下一页并下载。这是我到目前为止所拥有的:
driver.get('https://www.sosnc.gov/search/index/corp')
entity = "BOWMAN REAL ESTATE LLC"
try:
WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.XPATH,'//*[@id="SearchCriteria"]')))
driver.find_element_by_xpath('//*[@id="SearchCriteria"]').send_keys(entity)
driver.find_element_by_xpath("//*[@id='SubmitButton']").click()
except TimeoutException:
print("Loading took too much time! - 1")
try:
web_url = driver.page_source
soup = bs.BeautifulSoup(web_url, 'html.parser')