Пример #1
0
  w=eval(y.replace('false', 'False').replace('true','True'))
  d=w['recommendations']
  d2 = [[x['keyDate'][0:8], x['keyDate'][8:], x['list_price'][0]['formatted_price'], x['list_price'][1]['formatted_price']] for x in d]
  #d3 = set((x[i],x[i+2],i+1) for i in range(2) for x in d2)
  d3 = [[y+1, x[y], x[y+2]] for x in d2 for y in range(2)]
 except Exception ,e :
  retries+=1
  if retries>1:
   proxy = get_proxy()
  if retries>max_retries:
   print str(Start), str(Ret)
   traceback.print_exc()
   print "exception: " + str(e)
   print "Json: " + x
   #print "page: " + r3.text
   write_to_gabi(r3.text)
   cleandone=0
   Start = rz.get_date_from_list()
   retries=0
   # Start=Start + datetime.timedelta(days=1)
  continue

 retries=0
 d3=clean_dup_list(d3)
 d3.sort(key=lambda x: x[1])
 d4=[]
 cur_date=""
 min_price=0.0
 max_price=0.0
 for dirc in range(1,3):
  for i in d3:
Пример #2
0
 dict['pageToken'] = ""

 r2 = s.post('http://tickets.vueling.com/XmlSearch.aspx', data=dict, headers=headers)
 cleanr2 = ""
 if r2.status_code == 200:
  if list(find_all(r2.text, "basicPriceRoute")):
   cleanr2=r2.text[sorted(list(find_all(r2.text, "basicPriceRoute")))[0]-5:r2.text.find('SKYSALES.Util.createObject', sorted(list(find_all(r2.text, "basicPriceRoute")))[0])]
 else:
  retries+=1
  if retries>max_retries:
   print "Start:{0}, Ret:{1}. ".format(str(Start), str(Ret))
   cleandone=0
   Start=Start + datetime.timedelta(days=1)
   n+=1
  continue
 write_to_gabi(cleanr2)


 #try:
  #cleanr2=r2.text[sorted(list(find_all(r2.text, "basicPriceRoute")))[0]-5:r2.text.find('</tbody>', sorted(list(find_all(r2.text, "basicPriceRoute")))[-1])]
 #except IndexError :
  #retries+=1
  #if retries>max_retries:
   #print "Start:{0}, Ret:{1}. ".format(str(Start), str(Ret))
   #if debug_flag:
    #print "basicPriceRoute on HTML: {0}".format(list(find_all(r2.text, "basicPriceRoute")))
   #cleandone=0
   #Start=Start + datetime.timedelta(days=1)
   #n+=1
  #continue
Пример #3
0
ddict[
    'ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$PaxCountCHD'] = 0
ddict[
    'ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$PaxCountINFANT'] = 0
ddict[
    'ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$PaxCountADT'] = 1
ddict[
    'ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$ButtonSubmit'] = "Search"
ddict[
    '__EVENTTARGET'] = "ControlGroupRibbonAnonHomeView_AvailabilitySearchInputRibbonAnonHomeView_ButtonSubmit"
ddict['__VIEWSTATE'] = viewstate
ddict[new_token[0]] = new_token[1]
r2 = s.post('https://wizzair.com/en-GB/Search', data=ddict, headers=headers)
#r3 = s.get('https://wizzair.com/en-GB/Select', headers=headers)
#r4 = s.get('https://wizzair.com/en-GB/Select', headers=headers)
write_to_gabi(r2.text)

cur_date = Start.strftime("%d-%m-%Y")
prP = getFlight(cur_date)
prP.feed(r2.text)
flightsList.extend(prP.data)
flightsList = clean_dup(flightsList)
curs = db.cursor()
curs.execute("select id from companies where name='wizz'")
company_id = curs.fetchone()[0]

#for i in Out:
for i in flightsList:
    depp1 = datetime.datetime.strftime(
        datetime.datetime.strptime(i['dep_time'], "%H:%M") +
        datetime.timedelta(minutes=60), "%H:%M")
Пример #4
0
        r3 = s.post(url3, data=dict, headers=headers)
        x = r3.text[r3.text.find("generatedJSon"):r3.text.
                    find("\n", r3.text.find("generatedJSon"))]
        y = x[28:-4]
        w = eval(y.replace('false', 'False').replace('true', 'True'))
    except Exception, e:
        retries += 1
        if retries > 1:
            proxy = get_proxy()
        if retries > max_retries:
            print str(Start), str(Ret)
            traceback.print_exc()
            print "exception: " + str(e)
            print "Json: " + x
            #print "page: " + r3.text
            write_to_gabi(r3.text)
            cleandone = 0
            Start = rz.get_date_from_list()
            retries = 0
            # Start=Start + datetime.timedelta(days=1)
        continue

    retries = 0
    d = w['recommendations']
    d2 = [[
        x['keyDate'][0:8], x['keyDate'][8:],
        x['list_price'][0]['formatted_price'],
        x['list_price'][1]['formatted_price']
    ] for x in d]
    #d3 = set((x[i],x[i+2],i+1) for i in range(2) for x in d2)
    d3 = [[y + 1, x[y], x[y + 2]] for x in d2 for y in range(2)]
Пример #5
0
    if r2.status_code == 200:
        if list(find_all(r2.text, "basicPriceRoute")):
            cleanr2 = r2.text[
                sorted(list(find_all(r2.text, "basicPriceRoute")))[0] -
                5:r2.text.
                find('SKYSALES.Util.createObject',
                     sorted(list(find_all(r2.text, "basicPriceRoute")))[0])]
    else:
        retries += 1
        if retries > max_retries:
            print "Start:{0}, Ret:{1}. ".format(str(Start), str(Ret))
            cleandone = 0
            Start = Start + datetime.timedelta(days=1)
            n += 1
        continue
    write_to_gabi(cleanr2)

    #try:
    #cleanr2=r2.text[sorted(list(find_all(r2.text, "basicPriceRoute")))[0]-5:r2.text.find('</tbody>', sorted(list(find_all(r2.text, "basicPriceRoute")))[-1])]
    #except IndexError :
    #retries+=1
    #if retries>max_retries:
    #print "Start:{0}, Ret:{1}. ".format(str(Start), str(Ret))
    #if debug_flag:
    #print "basicPriceRoute on HTML: {0}".format(list(find_all(r2.text, "basicPriceRoute")))
    #cleandone=0
    #Start=Start + datetime.timedelta(days=1)
    #n+=1
    #continue

    retries = 0
Пример #6
0
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$OriginStation']="TLV"
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$DestinationStation']=DST
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$DepartureDate']=Start.strftime("%d/%m/%Y")
Ret = Start + datetime.timedelta(days=1)
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$ReturnDate']=Ret.strftime("%d/%m/%Y")
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$PaxCountCHD'] = 0
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$PaxCountINFANT'] = 0
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$PaxCountADT'] = 1
ddict['ControlGroupRibbonAnonHomeView$AvailabilitySearchInputRibbonAnonHomeView$ButtonSubmit'] = "Search"
ddict['__EVENTTARGET'] = "ControlGroupRibbonAnonHomeView_AvailabilitySearchInputRibbonAnonHomeView_ButtonSubmit"
ddict['__VIEWSTATE'] = viewstate
ddict[new_token[0]] = new_token[1]
r2 = s.post('https://wizzair.com/en-GB/Search', data=ddict, headers=headers)
#r3 = s.get('https://wizzair.com/en-GB/Select', headers=headers)
#r4 = s.get('https://wizzair.com/en-GB/Select', headers=headers)
write_to_gabi(r2.text)

cur_date=Start.strftime("%d-%m-%Y")
prP = getFlight(cur_date)
prP.feed(r2.text)
flightsList.extend(prP.data)
flightsList=clean_dup(flightsList)
curs = db.cursor()
curs.execute("select id from companies where name='wizz'")
company_id=curs.fetchone()[0]

#for i in Out:
for i in flightsList:
 depp1=datetime.datetime.strftime(datetime.datetime.strptime(i['dep_time'], "%H:%M")+datetime.timedelta(minutes=60), "%H:%M")
 depm1='00:00' if (int(i['dep_time'][0:i['dep_time'].find(':')]) == 0) else datetime.datetime.strftime(datetime.datetime.strptime(i['dep_time'], "%H:%M")-datetime.timedelta(minutes=60), "%H:%M")
 curs.execute("select * FROM flights WHERE direction=%s and dst=%s and date=%s and dep_time>%s and dep_time<%s and company=%s", (i['direction'],DST,str(i['year'])+"-"+str(i['month'])+"-"+str(i['day']),depm1,depp1,str(company_id)))