Hey guys, I’ve been working with some networking scripts lately in python and run into a bit of a problem.
I am trying to get movie times from: www.fandango.com.
I’ve created a function which will successfully generate the correct url to see the movie times, for example: getfromrottentomatoes(‘Moneyball’) returns: http://www.fandango.com/moneyball_136677/movietimes
If I plug this into Safari, I get a page that shows movie times for my area code with nearby theaters and all. Yet, if I get the text from the url using urlopen() this information is absent, there are no nearby theater or movie times listed which I can draw on for the code.
This is the function in its present state:
def get_movietimes(movie):
url = 'http://www.fandango.com/'
req = urllib2.Request(url)
f = urllib2.urlopen(req)
text = f.read()
text.replace('
','').replace(' ','')
re.DOTALL
link = str(re.findall(r'href=".+?>'+movie+'</a>',text)[0])
link = link.replace('href="','').replace(str(re.findall(r'/movieoverview.+',link)[0]),'')
text = urllib2.urlopen(urllib2.Request(link+'/movietimes')).read()
return link+'/movietimes'
I think the problem has something to do with cookies, how can I remedy this?