-
Notifications
You must be signed in to change notification settings - Fork 0
/
scraper.py
53 lines (33 loc) · 1.42 KB
/
scraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from urllib.request import urlopen
from bs4 import BeautifulSoup
root_booking_page = 'https://www.rumble-boxing.com/reserve/12900000002'
page = urlopen(root_booking_page)
parsed_page = BeautifulSoup(page, 'html.parser')
name_box = parsed_page.find('div', attrs={'data-classdate': '2018-04-09T06:00:00'})
class_id = name_box['id']
class_booking_page = 'https://www.rumble-boxing.com/book/' + class_id
booking_page = urlopen(class_booking_page)
parsed_booking_page = BeautifulSoup(booking_page, 'html.parser')
#print(parsed_booking_page)
loginForm = parsed_booking_page.find('form' , attrs = {'id': 'loginForm'})
loginKey = parsed_booking_page.find('input', attrs = {'name' : '_token'})['value']
loginUserName = '[email protected]'
loginPassword = 'cloudNinePassword'
payload = {
'_token': loginKey,
'uid': loginUserName,
'password': loginPassword
}
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# Add our headers
opener.addheaders = [('User-agent', 'RedditTesting')]
# Install our opener (note that this changes the global opener to the one
# we just made, but you can also just call opener.open() if you want)
urllib2.install_opener(opener)
# The action/ target from the form
authentication_url = 'https://www.rumble-boxing.com/authenticate'
print(loginKey)
#after login
spotcells = parsed_booking_page.find('div', attrs={'class': 'spotwrapper'})
#name = name_box.text.strip()