Python Requests Authentication Issue: Setting cookies?

I am trying to scrape a Hertz Rental Car API (URL below) to get pricing options for a specific itinerary. This is not on the disallow list on their robots.txt. I captured the payload from my browser stemming from the initial Hertz (Hertz.com) page populating the trip details (location, dates, pickup times) that is submitted to the request URL below. When I then hit the API below with my payload, headers (token and user agent), cookies, and URL (copied from my network tab), I get a 200 response, but never get my anticipated response as I would expect to see based on what I see in my browser network tab when performing in my browser. I tried making my headers just my token and not having cookies, but that gave me an Incapsula issue. I believe this is a cookie issue based on the response below, and I think my method of taking my Hertz.com response to set my cookie is not working. Need guidance/help.

Request URL: “https://www.hertz.com/rentacar/rest/hertz/v2/itinerary/vehicles”

Code:

import requests
import time

#URL 1 utilized to hit Hertz page and ideally return cookies to do API query with URL 2
url1="https://www.hertz.com"

url2="https://www.hertz.com/rentacar/rest/hertz/v2/itinerary/vehicles"

headers={"dtm_token":"HereIsAfakeTokenforAnExample",
          'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'}

#Payload copied from browser when performing the request from Hertz's homepage with trip details (location, dates, times)
#This payload is what is submitted by your browser when making a request to book a rental via URL2
params={'lastName': '', 'resSearch': False, 'showRentalAgreement': False, 'showEvRentalAgreement': False, 'goldAnytimeRes': False,
        'checkLIS': False, 'checkFPO': False, 'buttonLIS': False, 'buttonFPO': False, 'showBothElements': False,
        'cdpVerificationFailed': 0, 'forceResHomePage': '', 'href': '/rentacar/rest/home/form', 'confirmationNumber': '',
        'arrivingUpdate': '', 'defaultTab': '', 'militaryClock': 0, 'majorAirport': '', 'returnAtDifferentLocationCheckbox': '',
        'dropoffLocation': '', 'inpPickupAutoFill': 'Y', 'inpPickupStateCode': 'VA', 'inpPickupCountryCode': '', 'inpPickupSearchType': '3',
        'inpDropoffAutoFill': '', 'inpDropoffStateCode': '', 'inpDropoffCountryCode': '', 'inpDropoffSearchType': '', 'pickupHiddenEOAG': 'IADT26',
        'dropoffHiddenEOAG': '', 'memberOtherCdpField': '', 'cdpField': '', 'corporateRate': '', 'officialTravel': '',
        'pcNumber': '', 'typeInRateQuote': 'BEST', 'cvNumber': '', 'itNumber': '', 'originalRqCheckBox': '', 'checkDiscount': '',
        'affiliateMemberJoin': '', 'affiliateMemberID': '', 'affiliateCallCount': 0, 'hertzlinkActive': False, 'companyId': '',
        'pickupDay': '05/22/2024', 'pickupTime': '12:00', 'dropoffDay': '05/23/2024', 'dropoffTime': '12:00', 'no1ClubNumber': '',
        'selectedCarType': 'ACAR', 'ageSelector': '25', 'redeemPoints': '', 'fromLocationSearch': False,
        'recommendationBrowserInfo': {'appCodeName': 'Mozilla', 'appName': 'Netscape', 'appVersion':
                                      '5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
                                      'cookieEnabled': True, 'language': 'en-US', 'onLine': True, 'platform': 'MacIntel', 'product': 'Gecko',
                                      'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', 'visitorId': ''},
        'pickupLocation': 'Washington Dulles International Airport', 'inpPickupIsServedBy': 'N', 'inpPickupHasSpecialInstruction': 'N',
        'pickupDayStandard': '2024/05/22', 'dropoffDayStandard': '2024/05/23', 'inpPickupOptGoldAnytime': '', 'memberSelectedCdp': '', 'cdpRadioButton': ''}

response1=requests.get(url1, headers=headers)

#introducing sleep to make this less machine-like
time.sleep(2)

#used for debugging
print(response1.status_code)
print(response1.cookies)

#API request to get rental options and pricing
response2=requests.get(url2, headers=headers, params=params, cookies=response1.cookies)

#used for debugging
print(response2.status_code)
print(response2.text)
print(response2.cookies)

Terminal Results:
200
<RequestsCookieJar[]>
200
See response below for snippet of 85-line response
<RequestsCookieJar[]>

Response:

As you were browsing something about your browser made us think you were a bot. There are a few reasons this might happen:

  • You’ve disabled JavaScript in your web browser.
  • You’re a power user moving through this website with super-human speed.
  • You’ve disabled cookies in your web browser.
  • A third-party browser plugin, such as Ghostery or NoScript, is preventing JavaScript from running. Additional information is available in this support article.

To regain access, please make sure that cookies and JavaScript are enabled before reloading the page.

New contributor

JasonH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật