Advertisement
Delli

Untitled

Mar 2nd, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. f = open("code_movie.txt", "r") #opens file with name of "test.txt"
  2.  
  3. ss = f.read()
  4. ssSize = len(ss) # the size of ss
  5.  
  6.  
  7. def getValues(start, end):
  8. list = []
  9.  
  10. goal = start # how the string starts
  11. goalSize = len(goal) # the length of the string goal
  12. goalEnd = end # how the string ends
  13. goalEndSize = len(goalEnd) # the length of goalEnd
  14.  
  15. # both variables are set to -1 before beginning the process
  16. startPos = -1
  17. endPos = -1
  18.  
  19. for i in range(ssSize-goalSize+1):
  20. startPos = -1
  21. temp = ss[i:i+goalSize] # slicing the string from i to i+goalSize
  22.  
  23. if ( temp == goal):
  24. startPos = i+goalSize
  25. endPos = -1
  26.  
  27. for j in range(startPos, ssSize-goalSize+1):
  28. temp2 = ss[j:j+goalEndSize] # slicing the string from j to j+goalEndSize
  29. if ( temp2 == goalEnd ):
  30. endPos = j
  31. break
  32.  
  33. temp3 = "id=link_1_theater"
  34.  
  35. if ( ss[i:i+len(temp3)] == temp3 ):
  36. list.append("***")
  37.  
  38.  
  39. if ( startPos != -1 and endPos != -1 ):
  40. #print( ss[startPos:endPos] )
  41. list.append( ss[startPos:endPos] )
  42.  
  43. return list
  44.  
  45. addresses = getValues("<div class=address>", "<a href") # gets the addresses of the cienma
  46. times = getValues("</span><!-- -->", "‎</span>") # get the times of the moviefor i in range( len(addresses) ):
  47. if ( len(addresses) == 0 ):
  48. break
  49.  
  50. addresses.pop(0)
  51. print( addresses[0] )
  52. addresses.pop(0)
  53.  
  54. times.pop(0)
  55. for j in range( len(times) ):
  56. if ( times[0] != "***" ):
  57. print(times[0])
  58. times.pop(0)
  59. else:
  60. print("")
  61. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement