Отзыв по запросу в python - PullRequest
0 голосов
/ 28 апреля 2020

Я пытаюсь написать python скрипт для получения данных моего профиля с этой страницы: https://turo.com/us/en/login Используя f12 в firefox я получил заголовок, полезную нагрузку запроса, данные формы для полезной нагрузки запроса (тело запроса).

вот мой адрес электронной почты и пароль и основной URL-адрес API:

пароль: udannamondaypaul@gmail.com

имя пользователя: udannamondaypaul@gmail.com

URL-адрес API для почтовых запросов: https://turo.com/api/login

Войдите в систему с помощью firefox Я получаю фактические Json данные, для которых я, которые выглядит следующим образом:

{"alerts":{"bankAccountInfoNeeded":false,"searchExcludedVehicleIds":[],"unfinishedVehicleId":null},"allowedToAttemptPreApproval":true,"allowedToViewApprovalStatus":false,"bankAccountRequirement":null,"contactInformation":{"city":null,"email":"udannamondaypaul@gmail.com","emailVerified":false,"mobilePhone":null,"mobilePhoneVerified":false,"state":null,"streetAddress":null,"streetAddressLine2":null,"zip":null},"driver":{"allStarHost":false,"firstName":"udanna","id":15227582,"image":{"id":null,"originalImageUrl":"https://resources.turo.com/resources/img/profile/empty-profile_01_large__H7cdab5c9c7828f25764b49b1e54f0b39__.png","placeholder":true,"resizableUrlTemplate":null,"thumbnails":{"84x84":"https://resources.turo.com/resources/img/profile/empty-profile_01_medium__Ha869faa760f43a28da9ca8fbcde22c2d__.png","300x300":"https://resources.turo.com/resources/img/profile/empty-profile_01_large__H7cdab5c9c7828f25764b49b1e54f0b39__.png","225x225":"https://resources.turo.com/resources/img/profile/empty-profile_01_large__H7cdab5c9c7828f25764b49b1e54f0b39__.png","32x32":"https://resources.turo.com/resources/img/profile/empty-profile_01_tiny__H1d3b304549036bd19f7ef997a31d5761__.png"},"verified":false},"lastName":"monday","name":"udanna monday","url":"https://turo.com/drivers/15227582"},"driverLicenseCountryISO3alphaCode":null,"drivingCreditBalance":0.00,"drivingCreditBalanceWithCurency":{"amount":0.00,"currencyCode":"USD"},"drivingCreditBalanceWithCurrency":{"amount":0.00,"currencyCode":"USD"},"eligibleForChatSupport":false,"euNetverifyUser":false,"expertAtManualTransmission":null,"extraCount":0,"hasAdminLink":false,"hasEarnings":false,"hasEnabledVehicles":false,"hasValetLink":false,"imminentReservationIdAsRenter":null,"isEnrolledInOwnerProvidedProtection":false,"isGhosting":false,"isRejectedOrSuspended":true,"latestMobileAppLoginAt":null,"linkedAccounts":{},"loginMethod":"API_PASSWORD","ownerSince":null,"ownerWithApprovedTrips":false,"pendingActionsCount":0,"preferredProtectionLevel":null,"preferredProtectionLevelCountries":[],"shouldDisplayCaliforniaVinRequirementExplanation":false,"shouldResetPassword":false,"trackingId":"ARfxTn92RoSAD8_GEq3bog","turoGoActive":false,"turoGoEligible":false,"unfinishedListingId":null,"upcomingTripCount":0,"vehicleDeliveryLocationCount":0,"vehicles":[]}

Но используя python, чтобы сделать мой запрос, я получаю ошибку json data.

Вот мой python код:

import json
import requests
s = requests.Session()
url = "https://turo.com/api/login"
datas = {"username":"udannamondaypaul@gmail.com", "password":"udannamondaypaul@gmail.com"}

head = {
"content-type": "multipart/form-data; boundary=----WebKitFormBoundaryMxHFUWBzNpPLcBew",
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.9",
"origin": "https://turo.com",
"referer": "https://turo.com/iframes/login/index.html?locale=en_US",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
}

rr = s.post(url, data = json.dumps(datas), headers = head)

Сейчас пытаясь получить желаемые данные json, вместо этого я получил сообщение об ошибке

rr.text
u'{"error":"captcha_token_is_required","errors":[{"additionalDescription":null,"code":"captcha_token_is_required","data":null,"field":null,"message":"Captcha token is required"}],"message":"Captcha token is required"}'

Пожалуйста, как я могу получить мои фактические данные json с python? Я буду рад дополнительной руке на этом.

...