Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open("code_movie.txt", "r") #opens file with name of "test.txt"
- ss = f.read()
- ssSize = len(ss) # the size of ss
- def getValues(start, end):
- list = []
- goal = start # how the string starts
- goalSize = len(goal) # the length of the string goal
- goalEnd = end # how the string ends
- goalEndSize = len(goalEnd) # the length of goalEnd
- # both variables are set to -1 before beginning the process
- startPos = -1
- endPos = -1
- for i in range(ssSize-goalSize+1):
- startPos = -1
- temp = ss[i:i+goalSize] # slicing the string from i to i+goalSize
- if ( temp == goal):
- startPos = i+goalSize
- endPos = -1
- for j in range(startPos, ssSize-goalSize+1):
- temp2 = ss[j:j+goalEndSize] # slicing the string from j to j+goalEndSize
- if ( temp2 == goalEnd ):
- endPos = j
- break
- temp3 = "id=link_1_theater"
- if ( ss[i:i+len(temp3)] == temp3 ):
- list.append("***")
- if ( startPos != -1 and endPos != -1 ):
- #print( ss[startPos:endPos] )
- list.append( ss[startPos:endPos] )
- return list
- addresses = getValues("<div class=address>", "<a href") # gets the addresses of the cienma
- times = getValues("</span><!-- -->", "</span>") # get the times of the moviefor i in range( len(addresses) ):
- if ( len(addresses) == 0 ):
- break
- addresses.pop(0)
- print( addresses[0] )
- addresses.pop(0)
- times.pop(0)
- for j in range( len(times) ):
- if ( times[0] != "***" ):
- print(times[0])
- times.pop(0)
- else:
- print("")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement