<source lang="python">
sql = "INSERT INTO vacancies( title,time,types,session_id) VALUES ( %s,%s,%s,%s)"
for i,row in a.iterrows():
cursor.execute(sql, tuple(row))
# the connection is not autocommitted by default, so we must commit to save our changes
connection.commit()
</source>
<source lang="python">
num_of_page = 40
other_vacancies = [] # остальные вакансии будут валиться сюда
collected_data = [
{'pattern': ['#c', 'c#','c#','.net','core'], 'result': [] },
{'pattern': ['ruby'], 'result': []},
{'pattern': ['python'], 'result': []},
{'pattern': ['php'], 'result': []},
{'pattern': ['java','jаva','Java'], 'result': []},
{'pattern': ['javascript','node'], 'result': []},
{'pattern': ['golang','разработчик go','go-разработчик','go','go разработчик'], 'result': []},
{'pattern': ['c++','с++'], 'result': []}
]
for i in range(num_of_page):
URL ="https://career.habr.com/vacancies?divisions[]=backend&page=" + str(i+1)+ "&type=all"
page = requests.get(URL)
soup = bs(page.text, "html.parser")
vacancies_names = soup.find_all('a', class_='vacancy-card__title-link')
for name in vacancies_names:
for data in collected_data:
if any([x in name.get_text().lower() for x in data['pattern']]):
data['result'].append(name.get_text())
continue
else:
other_vacancies.append(name.get_text())
</source>
Подскажите тогда через какую библиотеку это можно сделать ?