def area(self, idx=None): D = c.green('@area') area = Page.scraper.get_element_BY(Target.Search.area) view = Select(area) options = view.options print(c.underline('Geographic Area:')) for i, op in enumerate(options): print('[{}] - {}'.format(c.orange(str(i)), c.blue(op.text))) if idx is None: idx = int(input('insert the number [i] -> ')) chs = options[idx].text options[idx].click() print(Page.I + self.I + D, c.underline(chs))
def catagory(self, idx=None): D = c.green('@catagory') category = Page.scraper.get_element_BY(Target.Search.category) view = Select(category) options = view.options print(c.underline('Category:')) for i, op in enumerate(options): print('[{}] - {}'.format(c.orange(str(i)), c.blue(op.text))) if idx is None: idx = int(input('\nInsert number [i] -> ')) chs = options[idx].text options[idx].click() print(Page.I + self.I + D, c.underline(chs))
def what(self, text=None): D = c.green('@what') if text is None: text = input('What you want search -> ') search = Page.scraper.get_element_BY(Target.Search.name) search.send_keys(text) print(Page.I + self.I + D, c.underline(text))
def next(self, check=False): D = c.green('@next') next_b = Page.scraper.get_element_BY(Target.ListAd.button_next) link = Page.scraper.find_elements_BY(next_b, Target.ListAd.link) if link: if check: return True Page.scraper.openUrl(link) print(Page.I + self.I + D, c.underline('Next')) return True print(Page.I + self.I + D, c.red('Finish')) return False
def links(self): D = c.green('@links') links = [] raw_ads = Page.scraper.get_nested_elements_from_root( Target.ListAd.list_link_element) for raw_ad in raw_ads: raw_link = Page.scraper.find_elements_BY( raw_ad, Target.ListAd.raw_link) link = Page.scraper.find_elements_BY(raw_link[0], Target.ListAd.link) links.append(link) print(Page.I + self.I + D, 'Founded links: ', c.underline(str(len(links)))) return links
def continue_button(self): D = c.green('@continue_button') b_continue = Page.scraper.get_element_BY( Target.Search.button_continue) b_continue.click() print(Page.I + self.I + D, c.underline('Continue'))
def goto_url(self): D = c.green('@goto_url') url = 'https://www.subito.it' Page.scraper.openUrl(url) print(Page.I + self.I + D, c.underline(url))