Example #1
0
def add_item(request, item, body, title):
    try:
        if item:
            item.append(title, body)
        else:
            Items.create(title, body)
    except Exception as error:
        print "Exception", type(error)

    return "ok"
Example #2
0
    def testBasic(self):
        body, title = get_text(),get_text()
        item = Items.create(body, title)

        self.assertTrue(item.text , 'text value')
        self.assertEqual(item.parent, None, 'appending to root')

        body, title = get_text(),get_text()
        child = Items.create(body, title, item)

        self.assertEqual(child.parent, item, 'appending to item')


        item2 = Items.create(get_text(),get_text())
        child.move(item2.id)

        self.assertEqual(child.parent, item2m, 'moving')
Example #3
0
def post_item():
    if Items.objects.count() < max_items:
        root_count = Items.root_count()
        if root_count<10:
            text = get_text()
            item = Items.create(text,text)
        elif root_count<10:
            item = Items.objects.order_by('?')[0]
        else:
            item = Items.objects.filter(parent__gte=1)[0]
        text = get_text()
        item.append(text, text)
Example #4
0
                            lambda x: x and "geo-georeferences" in x
                        }).span.text
                    else:
                        item["adress"] = "Не указан"
                    item["url"] = "https://www.avito.ru" + card.find(
                        "a")["href"]

                    # print(item["url"])
                    item["id"] = int(item["url"].replace(
                        "?src=bp_catalog", "").split("_")[-1])
                    it = Items.get_or_none(Items.item_id == item["id"])
                    urls_all.append(item["url"])
                    print(item)
                    if it is None:
                        print("Find new car", item["name"])
                        Items.create(item_id=item["id"], cost=item["cost"])
                    else:
                        if int(it.cost) != int(item["cost"]):
                            print(it.cost, item["cost"])
                            alarm(item, it.cost, item["cost"])

                            it.cost = item["cost"]
                            it.save()

                print(f"Checked {len(cards)}")
                time.sleep(random.randint(60, 70))

            print("=" * 70)
            print("Update complete")

        # except Exception as e: