def find_id(page): finder = Finder() finder.set_data(page) ref_pattern = "show_kontakt_new\('spec_id_new','(.+)'\)" ref = finder.find_references(ref_pattern) # print(ref) return ref[0]
def find_links(page): finder = Finder() finder.set_data(page) # print(page) ref_pattern = '<a href="(.+)" id="bx_.+" title="([А-Яа-я -]+)"' ref = finder.find_references(ref_pattern) return ref
def find_course(page): finder = Finder() finder.set_data(page) name_pattern = '"(.+)"' names = finder.find_references(name_pattern) price_pattern = '(\d+) дн / (\d+) р.' prices = finder.find_references(price_pattern) i0 = 0 for name in names: print(name) c = Course(site_id=s.id, name=name) c.save() of1 = Offer(course_id=c.id, duration_hours=0, duration_days=prices[i0][0], price=prices[i0][1]) of2 = Offer(course_id=c.id, duration_hours=0, duration_days=prices[i0 + 1][0], price=prices[i0 + 1][1]) i0 += 2 of1.save() of2.save() return []
def find_price(page): finder = Finder() finder.set_data(page) time_pattern = '(\d+) час[а-я]+,.+ (\d+) дн[а-я]+' time = finder.find_references(time_pattern) time = list(set(time)) price_pattern = '\d+ \d{3} руб.' price = finder.find_references(price_pattern) result = [] i0 = 0 for item in time: result.append({ 'days': item[1], 'hours': item[0], 'full_price': price[i0], 'special_price': price[i0 + 1] }) i0 += 2 return result
def find_links(page): finder = Finder() finder.set_data(page) ref_pattern = '<a href="/(.+)/" name=.+ class=h>([А-Я][а-я]+ [А-Я][а-я]+ [А-Я][а-я]+)</a>' ref = finder.find_references(ref_pattern) return ref
def find_phone(page): finder = Finder() finder.set_data(page) ref = finder.find_phone() return ref
def find_links(page): finder = Finder() finder.set_data(page) ref_pattern = 'href="(.+)" target="_blank">([А-Я][а-я]+ [А-Я][а-я]+ [А-Я][а-я]+)</a>' ref = finder.find_references(ref_pattern) return ref
def find_email(page): finder = Finder() finder.set_data(page) ref = finder.find_email() return ref