我正在抓取电报,我可以在聊天中使用 client.iter_messages 获取每个消息实例,但如果消息实例是位置共享消息,我想获取位置的纬度和经度。
for message in client.iter_messages('John'):
print(message.text) #prints message
------------------ #I want the latitude and longitude of the location if the message is a location share message and not a text message
如果有一点帮助,我们将不胜感激, 谢谢你。
message.geo
),否则不需要
location = message.geo #returns a GeoPoint object if the message is a location share message else returns None
if location is not None:
longitude = location.long
latitude = location.lat
print(longitude, latitude)