def test_words_in(): words_in = ['python', 'linux', 'flask'] jobs = Parser('python') info = jobs.vacancies_pars(words_in) words_d = {'python': 58, 'linux': 16.8, 'flask': 4} check = True for i in info[1]: for j in i: words = i[j] for w in words: if int(words[w]) == 0 or w == 'all_vacancies': continue else: prev = words_d[w] print(prev) if prev - 1 < int(words[w]) / 5 < prev + 1: pass else: check = False assert (check == True)
def main(): name = str(input('Введите название вакансии: ')) words_in = str(input('Введите ключевые слова через пробел: ')).split(' ') jobs = Parser(name) info = jobs.vacancies_pars(words_in) if info == 0: print(f'Ваканский по слову {name} не найдено') else: print(info[0]) print(info[1]) for i in info[0]: for j in i: print(f'На странице {int(j[0]) + 1} найдено {i[j]} ключевых слов') for i in info[1]: for j in i: words = i[j] for w in words: if int(words[w]) == 0 or w == 'all_vacancies': continue else: all_vac = int(words['all_vacancies']) d = round((int(words[w])/all_vac), 3) print(f'В среднем на странице №{int(j[0]) + 1} слово {w} встречается {d} раз')
def test_soup(check_connect): jobs = Parser('python') info = jobs.vacancies_pars('') assert (info != False)
def test_word(): jobs = Parser('дробовик') info = jobs.vacancies_pars('') assert (info == 0)