コード例 #1
0
 def getTrain(self, TN):
     URL_Train = "https://erail.in/rail/getTrains.aspx?TrainNo=" + str(
         TN) + "&DataSource=0&Language=0&Cache=true"
     try:
         return Prettify().TrainsToJson(get(URL_Train).text)[0]
     except:
         return {'error': 'Unexpected Server Response'}
コード例 #2
0
 def getRoute(self, TN):
     ID = self.getTrain(TN)
     try:
         ID['error']
     except KeyError:
         ID = ID['train_base']['train_id']
     URL_Route = "https://erail.in/data.aspx?Action=TRAINROUTE&Password=2012&Data1=" + ID + "&Data2=0&Cache=true"
     return Prettify().StationToJson(get(URL_Route).text)
コード例 #3
0
 def getTrain(self, TN):
     URL_Train = "http://erail.in/rail/getTrains.aspx?TrainNo=" + str(
         TN) + "&DataSource=0&Language=0&Cache=true"
     fh = urllib.request.urlopen(URL_Train)
     data = fh.read()
     try:
         return Prettify().TrainsToJson(data.decode("utf-8"))
     except:
         return {'error': 'Unexpected Server Response'}
コード例 #4
0
ファイル: RailIN.py プロジェクト: rohitraman/Rahi
 def getRoute(self,TN):
     ID = self.getTrain(TN)
     try:
         ID['error']
     except KeyError:
         ID = ID['train_base']['train_id']
     URL_Route = "https://erail.in/data.aspx?Action=TRAINROUTE&Password=2012&Data1="+ID+"&Data2=0&Cache=true"
     fh = urllib.request.urlopen(URL_Route)
     data = fh.read()
     return Prettify().StationToJson(data.decode("utf-8"))
コード例 #5
0
 def getFare(self, TN, F, T):
     URL_Fare = "https://erail.in/data.aspx?Action=GetTrainFare&train=" + str(
         TN) + "&from=" + F + "&to=" + T
     return Prettify().FareToJson(get(URL_Fare).text)
コード例 #6
0
 def getAvailability(self, TN, SSTN, DSTN, CLS, QT, DD, MM):
     URL_Avail = "https://d.erail.in/AVL_Request?Key="
     val = '_'.join([str(TN), SSTN, DSTN, CLS, QT, str(DD) + '-' + str(MM)])
     return Prettify().AvailToJson(get(URL_Avail + val).text)
コード例 #7
0
 def getAllTrains(self, F, T):
     URL_Trains = "https://erail.in/rail/getTrains.aspx?Station_From=" + F + "&Station_To=" + T + "&DataSource=0&Language=0&Cache=true"
     return Prettify().TrainsToJson(
         get(URL_Trains, headers={
             'User-Agent': gua()
         }).text)
コード例 #8
0
 def getFare(self, TN, F, T):
     URL_Fare = "https://erail.in/data.aspx?Action=GetTrainFare&train=" + str(
         TN) + "&from=" + F + "&to=" + T
     fh = urllib.request.urlopen(URL_Fare)
     data = fh.read()
     return Prettify().FareToJson(data.decode("utf-8"))
コード例 #9
0
 def getAllTrains(self, F, T):
     URL_Trains = "https://erail.in/rail/getTrains.aspx?Station_From=" + F + "&Station_To=" + T + "&DataSource=0&Language=0&Cache=true"
     fh = urllib.request.urlopen(URL_Trains)
     data = fh.read()
     return Prettify().TrainsToJson(data.decode("utf-8"))