gpt4 book ai didi

asp.net - 从 Expedia 获取酒店和房间图片列表

转载 作者:行者123 更新时间:2023-12-04 04:59:21 24 4
gpt4 key购买 nike

使用 Asp.Net,我想从 Expedia 获取酒店和所有相应的属性,例如酒店和房间图像。

它给出了图像之外的所有属性。我想通过酒店列表服务获取酒店和房间图片。我该怎么做才能实现这一目标?这是我的要求

var serviceClient = new HotelServicesClient("ExpediaServicePort");

var serviceRequest = new HotelListRequest();
serviceRequest.apiKey = _apiKey;
serviceRequest.locale = _culture == "tr" ? LocaleType.tr_TR : LocaleType.en_US;
serviceRequest.localeSpecified = true;
serviceRequest.currencyCode = _culture == "tr" ? "TRY" : "EUR";
serviceRequest.supplierType = "E";
serviceRequest.searchRadius = 100;
serviceRequest.searchRadiusSpecified = true;
serviceRequest.searchRadiusUnit = SearchRadiusUnitType.KM;
serviceRequest.searchRadiusUnitSpecified = true;
serviceRequest.arrivalDate = hotelListRequest.ArrivalAt.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
serviceRequest.departureDate = hotelListRequest.DepartureAt.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
serviceRequest.RoomGroup = new[] { new Room { numberOfAdults = hotelListRequest.AdultCount, numberOfChildren = hotelListRequest.ChildCount } };
serviceRequest.sort = SortType.PRICE;
serviceRequest.sortSpecified = true;
serviceRequest.numberOfResults = 50;
serviceRequest.numberOfResultsSpecified = true;

if (hotelListRequest.Latitude.HasValue && hotelListRequest.Longitude.HasValue)
{
serviceRequest.latitude = (float)hotelListRequest.Latitude.Value;
serviceRequest.latitudeSpecified = true;
serviceRequest.longitude = (float)hotelListRequest.Longitude.Value;
serviceRequest.longitudeSpecified = true;
}
else
{
serviceRequest.destinationString = hotelListRequest.City;
}

var hotelListResponse = new Entity.HotelList.HotelListResponse();

var response = serviceClient.getList(serviceRequest);

if (response.EanWsError != null)
throw new Exception(response.EanWsError.verboseMessage);

hotelListResponse.CacheKey = response.cacheKey;
hotelListResponse.CacheLocation = response.cacheLocation;
hotelListResponse.HasMore = response.moreResultsAvailable;

if (true)
{
foreach (var serviceHotel in response.HotelList.HotelSummary)
{
var hotel =

new Entity.Hotel
{
RefID = serviceHotel.hotelId,
Url = hotelUrl(serviceHotel.hotelId, _htmlDecodeFunc(serviceHotel.name)), .......

最佳答案

LIST api 不提供酒店图片,仅提供缩略图。
有三个地方可以获取图片,INFO(酒店图片)、ROOMIMAGES 和 AVAIL(房间图片)。

使用 LIST(或任何 api)提供的缩略图,您还可以通过替换最后的“_b”来获得各种格式。 '_l.' (风景),'_s.' (小),或 .... 此处列出了完整的替换值:
http://developer.ean.com/database_catalogs/relational/Image_Data
https://support.ean.com/entries/21965722-Additional-Image-Sizes-Available

请记住,您在生产中被限制为每秒 40 个请求,因此获取 LIST 结果的所有图像会很快消耗掉它。如果您使用的是他们数据库文件的本地版本,则可以从 LIST 中获取所有图像,而无需 ping 其 API。上面的第一个链接包含该文件的下载位置,只需要一些本地(无)SQL 集成。

关于asp.net - 从 Expedia 获取酒店和房间图片列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16339434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com