예제 #1
0
        for i in range(0, 100):
            x_pth = post_name_xpth_prefix + str(i) + post_name_xpth_suffix
            name = tree.xpath(x_pth)

            # If this element does not exist, continue
            if len(name) == 0:
                continue

            try:
                lst = Listing(base_url + name[0].attrib['href'])
            except AttributeError as ae:
                continue

            print(lst.get_title())
            if lst.get_title() != 'poor_err':
                if not db.listing_exists(lst):
                    db.save_listing(lst, u_of_t_address)
                    if lst.get_viability(
                            u_of_t_address
                    ) <= 200 and 'Wanted: ' not in lst.get_title():
                        mail.notify(lst, [
                            "*****@*****.**",
                            "*****@*****.**"
                        ], u_of_t_address)
                    print('** New listing saved **')
                else:
                    print('already saved')

            else:
                mail.email_dev(lst.url + "\n broke at \n" + URL,
                               ["*****@*****.**"])