Pages

AccessRequestPage

class autohandshake.AccessRequestPage(browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser)

The page on which users view and respond to Handshake access requests.

Parameters:browser (HandshakeBrowser) – a logged-in HandshakeBrowser
get_request_data(status: autohandshake.src.Pages.AccessRequestPage.RequestStatus = <RequestStatus.ALL: 'All'>) → List[dict]

Scrape access request data from the access request page for the specified request status.

Data will be returned as a list of dicts of the form:

{
    'user': 'Alex Student', # the requesting user's name
    'user_id': '1843927', # the requesting user's account ID
    'email': 'student.alex@gmail.com', # the requesting user's email
    'request_date': datetime.datetime(2019, 4, 12).date(), # the date the request was made
    'request': 'Student Access' # the request type, one of 'Student Access', 'Student Reactivation', or 'Mentor Access'],
    'status': 'waiting' # the request status, one of 'waiting', 'successful', 'rejected', or 'failed'
}

IMPORTANT: due to unknown limitations of Handshake’s server, the request page appears to only be capable of loading up to around 1750 rows before crashing the website. To guard against this, this method will only pull the first 69 pages of results. If you have more than 1725 requests in any status, you will be unable to pull the entire dataset for that status. The method will only return the first 1725 rows.

Parameters:status (RequestStatus) – the status type of requests to pull. By default, pull data for all requests
Returns:a list of request data dicts
Return type:list
class autohandshake.RequestStatus

The possible access request statuses:

  • WAITING - requests that have not yet been processed
  • SUCCESSFUL - requests that were approved
  • REJECTED - requests that were rejected
  • FAILED - requests that failed for other reasons
  • ALL - include all request statuses

Example

from autohandshake import HandshakeBrowser, AccessRequestPage, RequestStatus

with HandshakeBrowser(school_url, email) as browser:
    access_request_page = AccessRequestPage(browser)
    rejected_requests = access_request_page.get_request_data(RequestStatus.REJECTED)
    successful_requests = access_request_page.get_request_data(RequestStatus.SUCCESSFUL)
    all_requests = access_request_page.get_request_data()

AppointmentCalendarPage

class autohandshake.AppointmentCalendarPage(browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser)
Parameters:browser (HandshakeBrowser) – a logged-in HandshakeBrowser
get_unfilled_blocks(start_date: datetime.date, end_date: datetime.date = None, include_mediums: bool = False) → List[dict]

Get a list of unfilled appointment block data for the days from start_date up to (but not including) end_date.

The method returns a list of appointment block dicts of the form:

{
    'start_time': datetime.datetime(2019, 3, 7, 9, 30), # block start time
    'end_time': datetime.datetime(2019, 3, 7, 10, 30), # block end time
    'length': 60, # difference in minutes between start time and end time
    'status': 'unfilled', # status of the appointment
    'staff_name': 'Jane Coach', # the name of the staff member associated with the block
    'mediums': ['in-person', 'virtual'] # [OPTIONAL] the list of possible mediums for the open block
}
Parameters:
  • start_date (date) – the start date of the date range from which to pull the data
  • end_date (date) – the end date of the date range from which to pull the data. If no end date is specified, only pull data for start_date
  • include_mediums (bool) – whether or not to include the appointment block mediums in the data. Including the medium significantly increases the time required to pull the data.
Returns:

a list of appointment block dicts

Return type:

list

go_to_date(date: datetime.date)

Using the calendar’s datepicker, navigate to the specified date

Parameters:date (date) – the date to which to navigate on the calendar

Example

from autohandshake import HandshakeBrowser, AppointmentCalendarPage
import datetime

with HandshakeBrowser(school_url, email) as browser:
    calendar_page = AppointmentCalendarPage(browser)
    unfilled = calendar_page.get_unfilled_blocks(start_date = datetime.datetime(2019, 4, 3).date(),
                                                 end_date = datetime.datetime(2019, 4, 10).date(),
                                                 include_mediums = True)

AppointmentTypePage

class autohandshake.AppointmentTypePage(type_id: int, browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser)

A settings page for a single appointment type.

Parameters:
  • type_id (int) – the id of the appointment type to load
  • browser (HandshakeBrowser) – a logged-in HandshakeBrowser
get_settings() → dict

Get the settings for this page’s appointment type.

The method returns a dictionary of settings values of the form:

{
    'id': 238492,
    'name': 'STEM Resume Appointment',
    'description': 'An appointment for STEM students who want to improve their resume.',
    'length': 30,
    'categories': ['Resume/Cover Letter Review'],
    'drop_in_enabled': False,
    'pre_message': 'Please bring your resume with you to the appointment.',
    'pre_survey': None,
    'post_message': 'Thank you for stopping by!',
    'post_survey': 'Resume Review Satisfaction Survey',
    'staff_survey': 'Main Career Center Staff Survey',
    'school_years': ['Sophomore', 'Junior', 'Senior'],
    'cum_gpa_required': True,
    'cum_gpa': 3.0,
    'major_groups': ['major_group: Computer Science', 'major_group: Chemical Engineerng',
                     'major_group: Biology', 'indv_major: Biological Engineering'],
    'colleges': ['School of Engineering', 'School of Arts & Sciences'],
    'labels': ['appointments allowed'],
    'career_clusters': ['Science Careers', 'Engineering Careers']
}
Returns:a dictionary of all the appointment type settings fields
Return type:dict

Example

from autohandshake import HandshakeBrowser, AppointmentTypePage

stem_appt_type_id = 21849

with HandshakeBrowser(school_url, email) as browser:
    type_page = AppointmentTypePage(stem_appt_type_id, browser)
    settings = type_page.get_settings()

AppointmentTypesListPage

class autohandshake.AppointmentTypesListPage(browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser)

The overview settings page listing all appointment types

Parameters:browser (HandshakeBrowser) – a logged-in HandshakeBrowser
get_type_ids() → list

Get a list of appointment type IDs for your school

get_type_settings(how_many: int = None) → list

Get a list of settings objects for all appointment type settings.

The method returns a list of dicts, each of the form specified in autohandshake.AppointmentTypePage.get_settings()

Parameters:how_many (int) – if specified, the number of settings objects to collect. If None (the default), collect all settings. This argument is mainly for testing purposes, as downloading the full list of settings is prohibitively slow for testing.
Returns:a list of type settings objects for all appointment types
Return type:list

Example

from autohandshake import HandshakeBrowser, AppointmentTypesListPage

with HandshakeBrowser(school_url, email) as browser:
    types_page = AppointmentTypesListPage(browser)
    all_settings = types_page.get_type_settings()

InsightsPage

class autohandshake.InsightsPage(url_string: str, browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser)

Handshake’s custom data reporting page (powered by Looker)

Parameters:
  • url_string (str) – either a full insights URL or just the alphanumeric query string specifying the exact report
  • browser (HandshakeBrowser) – a logged-in HandshakeBrowser
download_file(download_dir: str, file_name: str = None, file_type: autohandshake.src.Pages.InsightsPage.FileType = <FileType.CSV: 'csv'>, max_wait_time: int = 300) → str

Download the Insights report’s data in a file of the specified type

Parameters:
  • file_type (FileType) – the type of file to download
  • download_dir (str) – the directory into which Insights will download the file. This is used to confirm that the file downloaded successfully, not to tell Insights where to download the file (Insights has no power over that).
  • file_name (str) – the name of the file to download. If None, default to Handshake’s standard naming of Insights files
  • max_wait_time (int) – the maximum amount of time to wait for the file to download without throwing an error
Returns:

the filepath of the newly-downloaded file

Return type:

str

get_data() → List[dict]

Get a JSON-like list of dict representation of the Insights report’s data

Returns:the Insight report’s data in list-of-dict/JSON-like format
Return type:list
set_date_range_filter(field_category: str, field_title: str, start_date: datetime.date, end_date: datetime.date)

Set a date range filter on the Insights report to the given start and end date.

Insights date filters are identified by a two-part name: the first part indicates the “category” or subject matter the date refers to, and the second part indicates the specific date field on that category.

For example: the filter for the start date of an appointment is called “Appointments Start Date Date.” In the Insights filter box, this title appears with the “Start Date Date” part in bold and the “Appointments” part in regular type. In this case “Appointments” is the field_category, and “Start Date Date” is the field_title. This methods requires both parts of the name in order to apply the given start and end dates to the correct filter.

IMPORTANT: at this time, this method only works on date range filters that follow the form “[Category] [Title] is in range [start] until (before) [end].” The method does not work on month or time filters, or on filters that do not represent a range between two time-less dates. Also, the filter must already exist in the Insights page; this method will not create a filter, merely modify the dates of an existing one.

Parameters:
  • field_category (str) – the date filter’s category name (see method description)
  • field_title (str) – the date filter’s title (see method description)
  • start_date (date) – the start date to use in the filter
  • end_date (date) – the end date to use in the filter. IMPORTANT: Handshake date ranges go up to but not including the end date, so a filter from 1/15/19 to 1/30/19 will NOT include any data from 1/30/19, for example.
class autohandshake.FileType

The possible download file types in Insights

  • EXCEL - an excel file with a .xlsx extension
  • TXT - a tab-separated .txt file
  • JSON - a json file with a .json extension
  • HTML - a .html file that can render the data table in a browser
  • MARKDOWN - a .md file that renders the table in markdown
  • PNG - a .png image of the data table
  • CSV - a comma-separated .csv file

Example

from autohandshake import HandshakeBrowser, InsightsPage, FileType
import datetime

# you can use either the full url or just the query string portion to instantiate the page.
full_url = 'https://app.joinhandshake.com/analytics/explore_embed?insights_page=ZXhwbG9yZS9nZW5lcmF0ZWRfaGFuZHNoYWtlX3Byb2R1Y3Rpb24vYXBwb2ludG1lbnRzP3FpZD1pcDFLd0ZlSmh4VVdobXYxa212U2xuJmVtYmVkX2RvbWFpbj1odHRwczolMkYlMkZhcHAuam9pbmhhbmRzaGFrZS5jb20mdG9nZ2xlPWZpbA=='
query_str = 'ZXhwbG9yZS9nZW5lcmF0ZWRfaGFuZHNoYWtlX3Byb2R1Y3Rpb24vYXBwb2ludG1lbnRzP3FpZD1pcDFLd0ZlSmh4VVdobXYxa212U2xuJmVtYmVkX2RvbWFpbj1odHRwczolMkYlMkZhcHAuam9pbmhhbmRzaGFrZS5jb20mdG9nZ2xlPWZpbA=='

with HandshakeBrowser(school_url, email) as browser:
    full_url_insights_page = InsightsPage(full_url, browser)
    # load the data into python as a list of dicts for further manipulation
    report_data = full_url_insights_page.get_data()

    query_insights_page = InsightsPage(query_str, browser)
    # change the date range filter of the report before downloading the results as an excel file
    query_insights_page.set_date_range_filter('Appointments', 'Start Date Date',
                                              start_date = datetime.datetime(2018, 1, 1),
                                              end_date = datetime.datetime(2019, 1, 1))
    query_insights_page.download_file(download_dir = 'C:\\Users\\user425\\Downloads\\',
                                      file_name = 'appointment_data_by_status.xlsx',
                                      file_type = FileType.EXCEL)

MajorSettingsPage

class autohandshake.MajorSettingsPage(browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser)
Parameters:browser (HandshakeBrowser) – a logged-in HandshakeBrowser
get_major_mapping() → List[dict]

Get a list of all the school’s majors and their associated major groups.

Returns:a list of major-to-major-group mapping dicts, of the form: {‘major’: ‘major name’, ‘groups’: [‘group 1’, ‘group 2’, etc]}
Return type:list

Example

from autohandshake import HandshakeBrowser, MajorSettingsPage

with HandshakeBrowser(school_url, email) as browser:
    major_settings_page = MajorSettingsPage(browser)
    mapping = major_settings_page.get_major_mapping()