【发布时间】:2017-04-27 19:59:44
【问题描述】:
我需要发送一个请求以从该网页获取所有游轮信息: https://www.ncl.com 问题是我在欧洲,我需要以美元为单位的价格。不知何故,页面“知道”我在哪里,我无法让它返回除欧元以外的货币。有没有办法以编程方式做到这一点? 到目前为止,我的要求是这样的:
session = requests.session()
headers = {
"authority": "www.ncl.com",
"method": "GET",
"path": "/ca/en/search_vacations",
"scheme": "https",
"accept": "application/json, text/plain, */*",
"connection": "keep-alive",
"referer": "https://www.ncl.com/ca/en/",
"cookie":"AkaUTrackingID=5D33489F106C004C18DFF0A6C79B44FD; AkaSTrackingID=F942E1903C8B5868628CF829225B6C0F; UrCapture=1d20f804-718a-e8ee-b1d8-d4f01150843f; BIGipServerpreprod2_www2.ncl.com_http=61515968.20480.0000; _gat_tealium_0=1; BIGipServerpreprod2_www.ncl.com_r4=1957341376.10275.0000; MP_COUNTRY=us; MP_LANG=en; mp__utma=35125182.281213660.1481488771.1481488771.1481488771.1; mp__utmc=35125182; mp__utmz=35125182.1481488771.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); utag_main=_st:1481490575797$ses_id:1481489633989%3Bexp-session; s_pers=%20s_fid%3D37513E254394AD66-1292924EC7FC34CB%7C1544560775848%3B%20s_nr%3D1481488775855-New%7C1484080775855%3B; s_sess=%20s_cc%3Dtrue%3B%20c%3DundefinedDirect%2520LoadDirect%2520Load%3B%20s_sq%3D%3B; _ga=GA1.2.969979116.1481488770; mp__utmb=35125182; NCL_LOCALE=en-US; SESS93afff5e686ba2a15ce72484c3a65b42=5ecffd6d110c231744267ee50e4eeb79; ak_location=US,NY,NEWYORK,501; Ncl_region=NY; optimizelyEndUserId=oeu1481488768465r0.23231006365903206",
"Proxy-Authorization": "Basic QFRLLTVmZjIwN2YzLTlmOGUtNDk0MS05MjY2LTkxMjdiMTZlZTI5ZDpAVEstNWZmMjA3ZjMtOWY4ZS00OTQxLTkyNjYtOTEyN2IxNmVlMjlk"
}
session.headers.update(headers)
url = "https://www.ncl.com/ca/en/search_vacations?cruise=1&cruiseTour=1&cruiseHotel=1&cruiseHotelAir=1&flyCruise=1&numberOfGuests=4294953449&state=undefined&pageSize=10¤tPage=" + str(page_counter) + "&sortBy=Featured&autoPopulate=f&from=resultPage"
page = session.get(url)
cruise_results = page.json()
我真的需要在不使用 VPN 隧道或代理的情况下这样做。 我使用的 cookie 不是我尝试过的第一个。上面的这个,是我通过隧道连接并从美国打开页面时得到的。没有做这项工作,所以我猜饼干没有涉及。在这方面我还是很陌生。
【问题讨论】:
标签: python python-3.x python-requests python-3.5