Ed
Хорошо, давайте тогда по частям. Сделайте для начала сам цикл и покажите что получилось. То, что дальше сделаем потом.
#-*- coding: cp1251 -*-
"""
Created on Tue Jun 05 19:35:11 2012
@author: Dimazzzzzz
"""#/usr/bin/python
import urllib
import numpy as np
rasnost = []
Data =[]
Blitz1 = []
Stavka2 = []
Igrok2 = []
Typs = [[]] * 10
for J in xrange(803311466, 803311500):
url='http://www.vezetmne.ru/auctions/'+str(J)
urllib.urlretrieve(url=url, filename='COD.html')
infile = open('COD.html')
lines = infile.readlines()
print J
for i in range(len(lines)):
line = lines[i]# так короче
if 'cbid=alterStep' in line:
rasnost.append(np.float(line.strip()[24:28]))
if 'item_bigcell' in line:
type1 = lines[i+1].strip()[10:40]
type2 = lines[i+2].strip()[10:40]
type3 = lines[i+3].strip()[10:40]
type4 = lines[i+4].strip()[10:40]
type5 = lines[i+5].strip()[10:40]
if 'Аукцион завершен' in line:
Data.append(line.strip()[-28:-19])
if 'Блиц-цена' in line:
Origin = line.strip()[91:97]
if '.' in Origin:
Orig = Origin[0:5]
else:
Orig = Origin
if '.' in Orig:
AA = Orig[0:4]
else:
AA = Orig
if '.' in AA:
BB = AA[0:3]
else:
BB = AA
if '.' in BB:
Blitz1.append(np.int(BB[0:2]))
else:
Blitz1.append(np.int(BB))
if '<div class="history" id="history">' in line:
Stavka1 = lines[i+3].strip()[21:50]# stavka.append(line.strip()[21:30])
Stavka2.append(np.float(Stavka1[0:Stavka1.find('р')]))
Igrok1 = lines[i+3].strip()[21:-24] # А вот для ника возьмем с минусом
Igrok2.append(Igrok1[Stavka1.find('р')+26:])
for q in xrange(1, 5):
if 'Участ' in type+str(q):
tyq = 1 # Не требует свободных лотов (+)
elif 'Кажд' in type+str(q):
tyq = 2 # Ограниченное количество ставок (+)
elif 'Лог' in type+str(q):
tyq = 3 #'Логины зашифрованы'(+)
elif 'Днев' in type+str(q):
tyq = 4 #'Дневной'(+)
elif 'Один' in type+str(q):
tyq = 5 #'С блефом' (+) - Внезапно ОО
elif 'Аукцион для' in type+str(q):
tyq = 6 #' Для новичков' (+)
elif 'Ставк' in type+str(q):
tyq = 7 #'На понижение'
elif 'Фикс' in type+str(q):
tyq = 8 #'Фиксированная цена'
elif '100' in type+str(q):
tyq = 9 #'100% скидка'
elif 'Бесп' in type+str(q):
tyq = 10 #'Бесплатные ставки'
else:
tyq = 0
Typs[0].append((1 if tyq == 1 or tyq == 1 or tyq == 1 or tyq == 1 or tyq == 1 else 0))
Typs[1].append((1 if tyq == 2 or tyq == 2 or tyq == 2 or tyq == 2 or tyq == 2 else 0))
Typs[2].append((1 if tyq == 3 or tyq == 3 or tyq == 3 or tyq == 3 or tyq == 3 else 0))
Typs[3].append((1 if tyq == 4 or tyq == 4 or tyq == 4 or tyq == 4 or tyq == 4 else 0))
Typs[4].append((1 if tyq == 5 or tyq == 5 or tyq == 5 or tyq == 5 or tyq == 5 else 0))
Typs[5].append((1 if tyq == 6 or tyq == 6 or tyq == 6 or tyq == 6 or tyq == 6 else 0))
Typs[6].append((1 if tyq == 7 or tyq == 7 or tyq == 7 or tyq == 7 or tyq == 7 else 0))
Typs[7].append((1 if tyq == 8 or tyq == 8 or tyq == 8 or tyq == 8 or tyq == 8 else 0))
Typs[8].append((1 if tyq == 9 or tyq == 9 or tyq == 9 or tyq == 9 or tyq == 9 else 0))
Typs[9].append((1 if tyq == 10 or tyq == 10 or tyq == 10 or tyq == 10 or tyq == 10 else 0))
print rasnost, '\n', Blitz1, '\n', Stavka2, '\n', Igrok2, '\n', Data
W = np.array(rasnost)
Blitz = np.array(Blitz1)
Stavka = np.array(Stavka2)
#Mtyp1 = np.array(Typ1)
#Mtyp1 = np.array(Typ1)
#Mtyp2 = np.array(Typ2)
#Mtyp3 = np.array(Typ3)
#Mtyp4 = np.array(Typ4)
#Mtyp5 = np.array(Typ5)
#Mtyp6 = np.array(Typ6)
#Mtyp7 = np.array(Typ7)
#Mtyp8 = np.array(Typ8)
#Mtyp9 = np.array(Typ9)
#Mtyp10 = np.array(Typ10)
Вот попытался, не могу объеденить q и type вот тут:
TypeError: unsupported operand type(s) for +: 'type' and 'str'
if 'Участ' in type+str(q):
tyq = 1 # Не требует свободных лотов (+)
elif 'Кажд' in type+str(q):
tyq = 2 # Ограниченное количество ставок (+)
elif 'Лог' in type+str(q):
tyq = 3 #'Логины зашифрованы'(+)
elif 'Днев' in type+str(q):
tyq = 4 #'Дневной'(+)
elif 'Один' in type+str(q):
tyq = 5 #'С блефом' (+) - Внезапно ОО
elif 'Аукцион для' in type+str(q):
tyq = 6 #' Для новичков' (+)
elif 'Ставк' in type+str(q):
tyq = 7 #'На понижение'
elif 'Фикс' in type+str(q):
tyq = 8 #'Фиксированная цена'
elif '100' in type+str(q):
tyq = 9 #'100% скидка'
elif 'Бесп' in type+str(q):
tyq = 10 #'Бесплатные ставки'
else:
tyq = 0