You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

  1. from flask import Flask, request
  2. from flask_restful import Resource, Api, abort
  3. import requests
  4. import json
  5. app = Flask( __name__ )
  6. api = Api( app )
  7. bus_data = open("databases/bus.json","a")
  8. def sendRequest( url, raw ):
  9. headers = {
  10. "User-Agent": "EGO Genel Mudurlugu-EGO Cepte-3.1.0 GT-I9500 7.1.2",
  11. "Content-Type": "application/x-www-form-urlencoded",
  12. "Content-Length": "0" }
  13. headers[ "Content-Length" ] = str( len( raw ) )
  14. r = requests.post( url, headers=headers, data=raw )
  15. content = r.content.decode( "cp1252" )
  16. content = content.replace( "Ý", "I" )
  17. content = content.replace( "ý", "i" )
  18. content = content.replace( "ð", "g" )
  19. content = content.replace( "þ", "s" )
  20. content = content.replace( "Þ", "S" )
  21. return content
  22. conn1 = sendRequest(
  23. 'http://88.255.141.70/mbl/android/connect.asp?SID=0.9672804113380772&VER=3.1.0&LAN=tr&UID=%7BACB78701' \
  24. '-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Connect',
  25. "UID=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&UPS=TRUE" )
  26. conn2 = sendRequest(
  27. 'http://88.255.141.66/mbl/android/connect.asp?SID=0.6654049014198404&VER=3.1.0&LAN=tr&UID=%7BACB78701' \
  28. '-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Start', "" )
  29. hatlar = sendRequest( 'http://88.255.141.66/mbl/android/action.asp?SID=0.8328642811845514&VER=3.1.0&LAN=tr&UID'
  30. '=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Hatlar', "QUERY=" )
  31. hatlar = hatlar.replace( "'", '"' )
  32. hatlar = json.loads( hatlar )
  33. class Transit( Resource ):
  34. def post( self ):
  35. args = request.form
  36. durak = sendRequest(
  37. "http://88.255.141.66/mbl/android/service.asp?SID=0.09912588645045828&VER=3.1.0&LAN=tr&UID=%7BACB78701" \
  38. "-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Otobusler", "DURAK=" + str( args[ "stop" ] ) )
  39. durak = durak.replace( "'", '"' )
  40. durak = json.loads( durak )
  41. return [durak,hatlar]
  42. if __name__ == '__main__':
  43. api.add_resource( Transit, '/transit', '/transit/' )
  44. app.run( host='0.0.0.0', port=5000 )