update_listings.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:rets-django 作者: bgirer 项目源码 文件源码
def fetch_listing_images(client, listing):
    """
    Makes use of some built-in rets-python methods to get image URLs for a listing. Note:
    this function (and get_listing_image()) were only necessary because rets-python failed
    to return anything useful with its Record.get_object() method when the location
    parameter was set to True.
    """
    headers = {'Accept': '*/*'}
    payload = {'Resource': 'Property', 'Type': 'Photo',
               'ID': _build_entity_object_ids(
                       listing.resource_key), 'Location': 1}
    encoding = 'utf-8'
    try:
        response = client.http._http_post(client.http._url_for('GetObject'),
                                          headers=headers, payload=payload)
    except (ProtocolError, ConnectionError, ConnectionResetError):
        client.http.login()
        response = client.http._http_post(client.http._url_for('GetObject'),
                                          headers=headers, payload=payload)
    multipart = MultipartDecoder.from_response(response, encoding)
    return multipart.parts
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号