Last active
May 17, 2021 10:06
-
-
Save jochen-eds/c2ac85f86d8abe0f2a28140e2f5369ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def e_Vergabe(Stichwort, Zeitraum = 'Letzte 7 Tage'): | |
driver = webdriver.Chrome("/usr/local/bin/chromedriver") | |
driver.get('https://www.evergabe-online.de/search.html?') | |
time.sleep(3) | |
Zustimmen_path = '/html/body/div[1]/div/div/a' | |
driver.find_element_by_xpath(Zustimmen_path).click() | |
Keyword_path = '//*[@id="keywordString"]' | |
driver.find_element_by_xpath(Keyword_path).send_keys(Stichwort) | |
time_path = '//*[@id="publishDateRange"]' | |
select = Select(driver.find_element_by_xpath(time_path)) | |
select.select_by_visible_text(Zeitraum) | |
time.sleep(3) | |
driver.find_element_by_xpath('/html/body/div[8]/div/div[4]/form/div[5]/div/button[2]').click() | |
time.sleep(3) | |
try: | |
no_pages = math.ceil(int(driver.find_element_by_class_name('navigatorLabel').text[-2:].strip())/10) | |
except: | |
no_pages = 1 | |
Bezeichnungen=[] | |
Vergabestellen=[] | |
Orte=[] | |
Verfahrensarten=[] | |
Fristen=[] | |
veröffentlicht=[] | |
Links=[] | |
i=0 | |
while i < no_pages: | |
#if i > 0: | |
time.sleep(3) | |
content = driver.page_source | |
soup = BeautifulSoup(content, features="lxml") | |
contentTable = soup.find('table', { "class" : "table-advanced table table-striped table-bordered"}) | |
rows = contentTable.find_all('tr', attrs={'even', "odd"}) | |
for row in rows: | |
Bezeichnung=row.find('a', attrs={'text-wrap'}).text | |
Vergabestelle=row.find('div', attrs={'class':'mandant-name'}).text | |
Ort=row.find('div', attrs={'class':'place'}).text | |
Verfahrensart=row.find('td', attrs={'class':'result_col_vergabeart'}).text | |
Frist=row.find('td', attrs={'class':'result_col_nextDeadline result_type_date'}).text | |
veröffentlich=row.find('td', attrs={'class':'result_col_releaseDate result_type_date'}).text | |
Linktemp = row.find('a', attrs={'text-wrap'})["href"] | |
Link= "https://www.evergabe-online.de/tenderdetails.html?1&id="+Linktemp[-6:] | |
Bezeichnungen.append(Bezeichnung) | |
Vergabestellen.append(Vergabestelle) | |
Orte.append(Ort) | |
Verfahrensarten.append(Verfahrensart) | |
Fristen.append(Frist) | |
veröffentlicht.append(veröffentlich) | |
Links.append(Link) | |
if i < (no_pages-1): | |
driver.find_element_by_class_name('next').click() | |
i += 1 | |
df = pd.DataFrame({'Bezeichnungen': Bezeichnungen, 'Vergabestellen': Vergabestellen, | |
'Orte': Orte, 'Verfahrensarten': Verfahrensarten, | |
'Fristen': Fristen, 'veröffentlicht': veröffentlicht, | |
'Links': Links}) | |
driver.quit() | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment