Closed otictac1 closed 9 years ago
That variable is actually stored in a hidden form field in the initial request to the /dining/ page. I used some regular expressions in the code to extract its value.
The getCookiesFromRequest function is a bit misleading, as it actually returns the request string, and writes directly to the global cookieJar. When I wrote it originally, I think it was primarily to get the cookies for future request, but then it became a useful point to grab a few other things from the response as well.
Okay, I had actually found that write after I wrote you as things will go sometimes. I'm trying to translate your ideas into Python. My project is going to be much smaller in scope than yours. I really just want to hard code a particular restaurant on a particular day and have it notify me if there is any availability.
I'm trying to post the appropriate data to the Disney finder site, but all I get back is the main Disney page (nothing with available times and such). I know I'm doing something wrong in the posting and/or (probably both) cookie management.
Any tips on how to do this in Python?
This is what I have so far, but it sadly does not do what I want:
import requests import urllib
session = requests.Session() session.headers.update({'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36'})
tokenRequest = session.get(url) start = tokenRequest.content.find('''id="pep_csrf"''') pep = tokenRequest.content[start+21:tokenRequest.content.find('>',start+22)-1] sessionCookies = tokenRequest.cookies
payload = { 'pep_csrf': pep, 'searchDate': '2015-11-12', 'skipPricing': 'true', 'searchTime':'80000714', 'partySize':'2', 'id':'293704;entityType=restaurant', 'type':'dining' }
raw = urllib.urlencode(payload) headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'referer': 'https://disneyworld.disney.go.com/dining/',
} times = session.post(url2, data=raw, cookies=sessionCookies, headers=headers)
print times.content
Hello sir,
I am trying to write a similar program for personal use and I really have a question about how you did something. Where do you get the pep_csrf from? I've inspected all of the cookies that I get from the get request and I don't see that anywhere? What am I missing?