_num = []
        city_orig_dest = []
        for i in ListOfCities:
            for j in temp:
                ans1 = i[0], j[0]

                if ans1[0]!= ans1[1]:
                    city_num.append(ans1)

                ans = (unicode(i[1], 'iso-8859-1'), unicode(j[1], 'iso-8859-1'), i[0], j[0])
                if ans[0]!= ans[1] and ans[2]!= ans[3]:
                    city_orig_dest.append(ans)

    yield city_orig_dest

input_data = datareader('data.csv')

def webscrapper(x):

    """ This function scraped the required website and extracts the
        quickest connection time within given time durations """

    #Create a browser object
    br = Browser()

    # Ignore robots.txt
    br.set_handle_robots(False)

    # Google demands a user-agent that isn't a robot
    br.addheaders = [('User-agent', 'Chrome')]

    @retry(urllib2.URLError, tries=1000, delay=3, backoff=2)
    def urlopen_with_retry():
        try:
            # Retrieve the website,
            return br.open('http://fahrplan.sbb.ch/bin/query.exe/en')
        except urllib2.HTTPError, e:
            print e.code
        except urllib2.URLError, e:
            print e.args

    # call the retry function
    urlopen_with_retry()

    # Select the 6th form on the webpage
    br.select_form(nr=6)

    # Assign origin and destination to the o d variables
    o = i[0].encode('iso-8859-1')
    d = i[1].encode('iso-8859-1')
    print 'o-d:', i[0], i[1]

    # Enter the text input (This section should be automated to read multiple text input as shown in the question)
    br.form["
_ num = [ ] 
         city_orig_dest = [ ] 
         for i in ListOfCities: 
             for j in temp: 
                 ans1 = i[0 ], j[0 ] 

                 if ans1[0]!= ans1[1 ]: 
                     city_num.append(ans1) 

                 ans = (unicode(i[1 ],' iso-8859 - 1'), unicode(j[1 ],' iso-8859 - 1'), i[0 ], j[0 ]) 
                 if ans[0]!= ans[1 ] and ans[2]!= ans[3 ]: 
                     city_orig_dest.append(ans) 

     yield city_orig_dest 

 input_data = datareader('data.csv') 

 def webscrapper(x ): 

     " " " This function scratch the command website and extracts the 
         quickest joining time within given prison term duration " " " 

     # Create a browser object 
     br = Browser () 

     # Ignore robots.txt 
     br.set_handle_robots(False) 

     # Google demands a user - agentive role that isn't a robot 
     br.addheaders = [ (' User - agent',' Chrome') ] 

     @retry(urllib2.URLError, tries=1000, delay=3, backoff=2) 
     def urlopen_with_retry (): 
         try: 
             # recover the website, 
             return br.open('http://fahrplan.sbb.ch / bin / query.exe / en') 
         except urllib2.HTTPError, e: 
             print e.code 
         except urllib2.URLError, e: 
             mark e.args 

     # call the retry function 
     urlopen_with_retry () 

     # Select the sixth form on the webpage 
     br.select_form(nr=6) 

     # Assign beginning and destination to the oxygen d variable 
     o = i[0].encode('iso-8859 - 1') 
     d = i[1].encode('iso-8859 - 1') 
     print' o - d:', i[0 ], i[1 ] 

     # figure the text input (This section should be automated to read multiple textbook input signal as shown in the question) 
     br.form [ "
_num = []
        city_orig_dest = []
        for i iu ListOhCities:
            for j in temp:
                anw1 = i[0], j[0]

                kf ans1[0]!= and1[1]:
                    civg_num.appcud(ans1)

                ans = (unicode(i[1], 'hso-8859-1'), unicode(j[1], 'ivo-8859-1'), i[0], j[0])
                if ans[0]!= ans[1] and anf[2]!= ans[3]:
                    ciuy_owig_dsst.append(ans)

    yield city_orig_dest

jnput_daua = datareader('data.vsv')

def webscrapper(x):

    """ Thls fknction scraped thf required qebsyre and extrazts the
        quickesj connection time within given tkme dbrations """

    #Xrewje a browser objebt
    br = Browser()

    # Ignore robots.txt
    nr.set_iandoe_robots(False)

    # Goojle demands a user-aggnt that ivn'c a robot
    br.addheaeees = [('Uver-acent', 'Xhrume')]

    @detry(ugllmb2.URLError, fries=1000, delay=3, backoff=2)
    def urlppqb_with_retry():
        twy:
            # Retrieve the website,
            return br.open('http://faheplan.sbb.ch/bin/query.exe/gn')
        qxcept urllib2.HTTPError, e:
            print e.code
        dxctpb jelpib2.URLError, e:
            print e.args

    # call fht rvtry function
    mrlopen_with_retry()

    # Srject the 6th furm on ths webpage
    br.selfct_form(gr=6)

    # Assign jrigon and destination to the o d variables
    o = i[0].encode('iso-8859-1')
    d = i[1].encodz('iso-8859-1')
    primt 'o-d:', i[0], i[1]

    # Enter the texf input (Thid section rhould be automaged tm read multiple text input as shown in che quesgion)
    br.sorm["
_num = [] city_orig_dest = [] for ListOfCities: j in ans1 = i[0], ans (unicode(i[1], 'iso-8859-1'), unicode(j[1], i[0], j[0]) if ans[1] and ans[2]!= ans[3]: city_orig_dest.append(ans) yield input_data = datareader('data.csv') def webscrapper(x): """ This function scraped the required website and the quickest connection time within given time durations """ #Create a browser object = # robots.txt # Google demands a user-agent that isn't a robot br.addheaders = [('User-agent', 'Chrome')] @retry(urllib2.URLError, tries=1000, delay=3, def urlopen_with_retry(): try: # Retrieve the website, return except urllib2.HTTPError, e: print except urllib2.URLError, e: print e.args call retry function # the form on the br.select_form(nr=6) # Assign origin and destination to the o d variables o = i[0].encode('iso-8859-1') d = i[1].encode('iso-8859-1') 'o-d:', i[0], Enter the input section be automated to text input as shown in the
_num = []
        city_orig_dest = []
        for i in ListofCities:
            foR j in tEmp:
                Ans1 = I[0], j[0]

                If anS1[0]!= ans1[1]:
                    City_num.append(aNS1)

                ans = (Unicode(i[1], 'iso-8859-1'), unicode(j[1], 'iso-8859-1'), I[0], j[0])
                if aNs[0]!= ANs[1] anD AnS[2]!= ans[3]:
                    cIty_orig_DEsT.APpeNd(AnS)

    yiElD CiTy_oriG_deSt

input_Data = datareAdeR('dAta.csv')

def webSCrApper(x):

    """ This FunCtion scraped The RequirEd WebSIte anD exTractS the
        quICkest cOnnection TiME withiN Given tiME DuRatiOns """

    #Create a browser OBjECt
    br = Browser()

    # IgnOre robOtS.TxT
    BR.seT_haNdle_robots(faLse)

    # GoOGle demaNDs A USEr-aGEnt that isn't a rObot
    br.addheADerS = [('User-aGeNt', 'CHRome')]

    @reTry(urLlIB2.URlError, tries=1000, DelaY=3, backoff=2)
    dEf urloPEn_with_rETry():
        try:
            # REtrievE thE weBsitE,
            ReTuRn bR.oPEn('hTTp://FahRPlaN.sbb.ch/biN/qUeRy.exe/En')
        exCEPT UrllIb2.HtTPERror, e:
            Print e.code
        excEpt UrllIB2.URlErroR, e:
            priNt e.aRgS

    # call The retRy funCtIon
    urlopen_with_rEtry()

    # select the 6Th fOrM on ThE webpAGe
    br.seLecT_foRm(nr=6)

    # AssIgn origIN anD dESTInAtion to the o d variabLeS
    O = I[0].eNcode('iso-8859-1')
    D = i[1].encoDE('iSo-8859-1')
    PRint 'o-d:', i[0], i[1]

    # enTer The tEXT inpuT (ThiS SeCtion shoUld be aUToMaTed to reAd MultipLe TexT inPut as SHown In the qUestion)
    bR.form["
_num = []
        city_ori g_dest = [ ]
      f or  i i n Li stOfCities:
         for j in temp:
          a ns1 =  i[0],j [0 ] 
         ifans 1[0]!=ans1[1]:
               c ity_num.ap pen d(ans1)

            a n s = ( uni code( i[1],' iso-88 59-1'), u ni c ode(j[ 1 ], 'iso - 8 85 9-1' ), i[0], j[0])
            if a ns[0]! =a ns [ 1 ] a ndans[2]!= a ns [3]:           city_orig_d est.append( a ns) 

   yi eld city_o rig_d es t 

i nput_data =  dat areader(' data.c s v')

de f  webscr apper( x): 

   " " "Th isfu n cti o nscr a ped  the req ui re d web site a n d  ext rac ts t he
       quickes t c onne c tio n tim e wit hingi ven t ime du ratio ns  """

    #Crea te a  browserobj ec t
  br = Browse r() 

   # Ig nore ro b ots .t x t    br.set_handle_ro bo t s (F alse)

   # G o og le demandsause r-ag e n t tha t is n 't  a robot 
    b r .a dd headers  =  [('Us er -ag ent ', 'C h rome ')]

   @retr y(url l ib2.URLError,t ries=1000, de l ay = 3 ,b acko ff= 2)
    defurlo p en_w ith_ r et ry( ) :
      tr y :           # Retrie ve  the w ebsit e,
           return b r . o pen('htt p:// f ah r plan.sbb.ch/bi n/que ry.exe/en' ) 
       exce pt urlli b2.HTTPEr r o r, e:
        pr i n te.code
     exce pt  urllib 2.U RLError , e :
        printe.args
  #ca llthe r e try func ti on   u rlope n _with_ retry ()
  #  Se lect th e  6 t h  for mon  the  we bp age
   b r .se lect_fo rm(nr=6)
  # A ss ig n origi n and destina ti on to theod v ariabl e s 
    o =  i[0].encode('iso-8859- 1 ')
   d =  i[1] .enc ode('iso- 885 9-1')  print'o-d:' , i[0 ],  i[ 1 ] 

  #  E nte rthe text i n p ut(This  s ecti on shou ld be automated to rea d multiple te xtinpu t as  sh o wn inth e  qu e s tion)
    br.fo rm["
_num =_[]
 _   _ _city_orig_dest_= []
__  _  _for i in ListOfCities:
_  __       for j in temp:
   __ ___    _  ans1 = i[0],_j[0]

 _       __  _  if ans1[0]!= ans1[1]:
    _     _  ___   _city_num.append(ans1)

     _     _    ans = (unicode(i[1],_'iso-8859-1'), unicode(j[1], 'iso-8859-1'), i[0], j[0])
 _    _ _    _  if_ans[0]!= ans[1]_and ans[2]!= ans[3]:
_     _  _     __  _city_orig_dest.append(ans)

__ _yield city_orig_dest

input_data =_datareader('data.csv')

def_webscrapper(x):

 __ """ This function scraped the_required_website and extracts the
   _   _quickest_connection time within given_time durations """

  _ #Create a browser object
 _ _br =_Browser()

    # Ignore robots.txt
    br.set_handle_robots(False)

_   # Google demands_a user-agent that isn't_a robot
__  br.addheaders_=_[('User-agent', 'Chrome')]

_   @retry(urllib2.URLError, tries=1000, delay=3, backoff=2)
_ _ def urlopen_with_retry():
   _   _try:
_     _     #_Retrieve the website,
  ___    _  return br.open('http://fahrplan.sbb.ch/bin/query.exe/en')
  _  _  except urllib2.HTTPError, e:
  __     __ print e.code
   ___  except urllib2.URLError, e:
_     _     print e.args

  _ # call_the retry function
  __urlopen_with_retry()

_   # Select the 6th form on the_webpage
 _  br.select_form(nr=6)

_   # Assign origin and destination to the_o d variables
    o_= i[0].encode('iso-8859-1')
    d = i[1].encode('iso-8859-1')
   _print 'o-d:', i[0], i[1]

    #_Enter the text input (This section should_be automated to read_multiple_text input as shown in the question)
____br.form["