Exemple #1
0
    def run(self):
        soup = self.getSoup()
        if not soup:
            return False
        table = soup.find('table', {'id': 'itemPlaceholderContainer'})
        if not table:
            return False
        for tr in table.findAll('tr', {'valign': 'top'}):
            td = tr.findAll('td')
            offer = self.getOffer(td[0].a.string)
            if not offer:
                continue

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=td[1].a.string,
                clicks=td[2].a.string,
                payout=decimal.Decimal(str(offer.payout)),
                EPC=td[6].a.string[1:],
                revenue=decimal.Decimal(td[5].a.string[1:])
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #2
0
    def run(self):
        if not self.account:
            return False

        self.account.checked()
        if 'offer_num' not in self.data:
            return False
        offer = self.getOffer(self.data['offer_num'])
        if not offer:
            print "no offer %s" % self.data['offer_num']
            return False

        self.checkEarnings(offer)
        earnings = Earnings(
            offer=offer,
            network=self.account.network,
            niche=offer.niche,
            campaign=str(self.data['campaign']),
            clicks=int(self.data['clicks']),
            payout=decimal.Decimal(str(offer.payout)),
            revenue=decimal.Decimal(self.data['revenue'])
        )
        earnings.save()

        if 'today_revenue' in self.data['today_revenue']:
            self.account.setRevenue(self.data['today_revenue'])
        return True
Exemple #3
0
    def run(self):
        soup = self.getSoup()
        if not soup:
            return False
        for tr in soup.find('div', {'id': 'content'}).find('table', {'class': 'bordered'}).findAll('tr'):
            td = tr.findAll('td')
            if not td[0].a:
                continue

            campaign = td[0].a.string
            try:
                offer = Offer.objects.get(name=campaign, account=self.account, network=self.account.network)
            except:
                continue

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=campaign,
                payout=td[5].a.string[1:],
                EPC=td[3].string[1:],
                clicks=td[1].string,
                revenue=decimal.Decimal(td[6].string[1:])
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #4
0
    def run(self):
        try:
            soup = self.getSoup()
        except:
            return False
        if not soup:
            return False
        div = soup.find('div', {'class': 'table-data-div'})
        if not div:
            return False

        for tr in div.findAll('tr'):
            td = tr.findAll('td')

            offer = self.getOffer(td[0].a.string)
            if not offer:
                continue

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=td[1].a.string,
                payout=td[5].string.strip()[1:],
                clicks=td[2].string,
                EPC=td[6].string.strip()[1:],
                revenue=decimal.Decimal(td[7].string.strip()[1:])
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #5
0
    def run(self):
        soup = self.getSoup()
        if not soup:
            return False
        div = soup.find('div', {'id': 'ctl00_ContentPlaceHolder1_divReportData'})
        if not div:
            return True

        for tr in div.findAll('table')[1].findAll('tr'):
            td = tr.findAll('td')

            if len(td) == 1 or not td[2].find('img', {'title': 'Daily Breakout'}):
                continue

            offer = self.getOffer(td[3].string)
            if not offer:
                continue

            if td[4].span:
                span = td[4].span['onmouseover'][5:]
                campaign = span[:span.find("'")]
            else:
                campaign = td[4].string

            aprovedCTRblock = td[12].span if td[12].span else td[12]

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=campaign,
                status=td[5].span.string,
                payout="%.2f" % float(td[6].string[1:]),
                impressions=int(td[7].string),
                clicks=int(td[8].string),
                qualified_transactions=int(td[9].string),
                aproved=int(td[10].string),
                CTR=td[11].string[:-2],
                aprovedCTR=aprovedCTRblock.string[:-2],
                eCPM=td[13].string[1:],
                EPC=td[14].string[1:],
                revenue=decimal.Decimal(td[15].string[1:])
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #6
0
    def run(self):
        soup = self.getSoup()
        if not soup:
            return False
        table = soup.find('table', {'class': 'recordTable'})
        if not table:
            return False

        for tr in table.findAll('tr'):
            td = tr.findAll('td')
            if not td[1].b:
                continue
            link = td[1].b.a
            if not link or not link.string:
                continue

            end = link['href'].find('&')
            if end == -1:
                end = len(link['href'])
            offer_num = link['href'][link['href'].find('=') + 1: end]
            offer = self.getOffer(offer_num)
            if not offer:
                continue

            block = str(td[12].b)
            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=link.string,
                status=td[12 + self.inc].string.lower(),
                payout=td[10 + self.inc].a.string[1:-5],
                impressions=td[2].string,
                clicks=td[3].string,
                CTR=td[5].string[:-1].replace(',', ''),
                EPC=0 if td[9 + self.inc].string == 'N/A' else td[9 + self.inc].string[1:],
                revenue=decimal.Decimal(block[block.find('$') + 1: block.find('a') - 1] if self.inc else td[11].b.string[1:])
                #decimal.Decimal((block[block.find('$') + 1 : block.find('a') - 1]))
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #7
0
    def run(self):
        try:
            soup = self.getSoup()
        except:
            return False

        if not soup:
            return False
        block = soup.find('tbody', {'id': 'pagingBody'})
        if not block:
            return True
        for tr in block.findAll('tr'):
            td = tr.findAll('td')

            href = td[0].a['href']
            offer_num = href[href.rfind('/') + 1:]

            offer = self.getOffer(offer_num)
            if not offer:
                continue

            link = td[0].a.string
            b = link.find('(')
            clicks = int(td[2].string)

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=link[link.find('-') + 2: len(link) if b == -1 else b - 1],
                payout=td[4].string[1:],
                clicks=clicks,
                impressions=td[1].string,
                revenue=float(td[5].string[1:]) * clicks
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #8
0
    def run(self):
        if not hasattr(self.account, 'api'):
            print "Warning! Add api for account %s" % self.account
            return False

        yesterday = self.now - datetime.timedelta(days=1)
        yesterday = "%s/%s/%s" % (yesterday.month, yesterday.day, yesterday.year)

        self.url = "%saffiliates/api/1/reports.asmx/CampaignSummary?affiliate_id=%s&api_key=%s&start_date=%s&end_date=%s" \
                   % (self.account.network.url, self.account.api.affiliate_id, self.account.api.api_key,
                      yesterday, "%s/%s/%s" % (self.now.month, self.now.day, self.now.year))

        print 'extracting from ' + self.url
        try:
            soup = BeautifulStoneSoup(urllib2.urlopen(self.url))
        except:
            return False
        if not soup:
            return False
        for i in soup.findAll('campaign'):
            offer = self.getOffer(i.offer_id.string)
            if not offer:
                continue

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=i.vertical_name.string,
                payout=i.price.string,
                clicks=i.clicks.string,
                impressions=i.impressions.string,
                revenue=decimal.Decimal(i.revenue.string),
                EPC=i.epc.string
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #9
0
    def run(self):
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(CookieJar()))
        print "opening %s " % self.loginurl
        print "login %s %s ... " % (self.account.user_id, self.account.password)
        response = opener.open(self.loginurl, urllib.urlencode({
            self.username_field: self.account.user_id,
            self.password_field: self.account.password
        }))

        today = "%s/%s/%s" % (self.now.year, self.now.month, self.now.day)
        print "opening %s ..." % self.url
        print "params: %s " % "sRange=%s&eRange=%s&cRange=&groupBy=campaign" % (today, today)

        data = "sRange=%s&eRange=%s&cRange=&groupBy=campaign" % (today, today)
        soup = BeautifulSoup(opener.open(self.url, data).read())
        table = soup.find('table', {'id': 'table_mytraffic'})
        if not table:
            return True
        records = []
        for tr in table.tbody.findAll('tr'):
            offer = self.getOffer(tr.find('td', {'class': 'td_camp_id'}).string)
            if not offer:
                continue

            self.checkEarnings(offer)
            earnings = Earnings(
                offer=offer,
                network=self.account.network,
                niche=offer.niche,
                campaign=tr.find('td', {'class': 'td_camp_title'}).a.string,
                clicks=tr.find('td', {'class': 'td_clicks cl'}).string,
                payout=decimal.Decimal(str(offer.payout)),
                EPC=tr.find('td', {'class': 'td_ECPC'}).string[1:],
                revenue=decimal.Decimal(tr.find('td', {'class': 'td_revenue'}).string[1:]),
            )
            earnings.save()
            self.today_revenue += earnings.revenue
        return True
Exemple #10
0
        def saveEarnings(trs):
            for tr in trs:
                td = tr.findAll('td')
                if not td[1].nobr:
                    continue
                name = td[1].nobr.string
                offer = self.getOffer(name[1:name.find(')')])
                if not offer:
                    continue

                self.checkEarnings(offer)
                earnings = Earnings(
                    offer=offer,
                    network=self.account.network,
                    niche=offer.niche,
                    campaign=name[name.find(')') + 1:],
                    payout=decimal.Decimal(str(offer.payout)),
                    clicks=int(td[3].a.string),
                    revenue=decimal.Decimal(td[7].div.string[1:]),
                    EPC=decimal.Decimal(td[6].string[1:])
                )
                earnings.save()
                self.today_revenue += earnings.revenue