Example #1
0

with open("spys.txt", "r") as f:
    spys = f.readlines()


i = 0
steals = []
while i < len(spys):
    if spys[i].startswith('Sie konnten folgende Ressourcen stehlen'):
        name = spys[i-8].split('\t')
        name = name[1].split(')')[0]
        name, syn = name.split(' (#')
        if spys[i+7].startswith('Summe'):
            val = spys[i+7].strip()
            amount = string_to_int(val.split(' ')[1])
        else:
            val = spys[i+3].strip()
            kind, amount = re.split('\s+', val)
            amount = string_to_int(amount)
            if kind == "Erz":
                amount *= 6
            if kind == "Foschungspunkte":
                amount *= 16
            if kind == "Energie":
                amount *= 1.2

        steals.append((name, syn, amount))
    i += 1

Example #2
0
File: area.py Project: dfherr/syn
def scrape_area_cost(html):
    return [
        string_to_int(area_cost_regex.search(html).group(1)),
        string_to_int(area_construction_regex.search(html).group(1))
    ]
Example #3
0
File: area.py Project: dfherr/syn
def scrape_buildings(html):
    return [
        string_to_int(building_cost_regex.search(html).group(1)),
        string_to_int(building_free_regex.search(html).group(1))
    ]
Example #4
0
    '7': 'false',
    '8': 'false',
    '9': 'false',
    '10': 'false',
}

if __name__ == '__main__':
    session = LoggedInSession.get_session()
    r = session.get(links['news'], params=params)

    sales = map(
        list,
        sales_regex.findall(r.content)  # + tender_regex.findall(r.content)
    )
    for sale in sales:
        sale[0] = string_to_int(sale[0])
        sale[2] = string_to_int(sale[2])
    df = pd.DataFrame(sales)
    grouped = df.groupby(1).sum()

    print(grouped)

    pd.set_option('display.max_rows', 1000)

    with open(Path(RES_DIR, 'home/test_log'), 'w') as f:
        f.write(r.content)
        f.write('\n\n\n\n')
        f.write(str(df))
        f.write(str(grouped))

    session.save_session()