def inline(message, matches, chat_id, step):
query_id, from_id, query = telepot.glance(message, flavor='inline_query')
response = requests.get(query)
soup = BeautifulSoup(response.text, "html.parser")
image = soup.find("meta", {"property": "og:image"})
video = soup.find("meta", {"property": "og:video"})
if video:
width = soup.find("meta", {"property": "og:video:width"})
height = soup.find("meta", {"property": "og:video:height"})
return [InlineQueryResultVideo(
id=str(uuid.uuid4()), description='Instagram Video', title="Instagram Video", mime_type="video/mp4",
thumb_url=image['content'], video_url=video['content'], video_width=int(width['content']),
video_height=int(height['content']))]
elif image:
return [InlineQueryResultPhoto(
id=str(uuid.uuid4()), title="Instagram Photo",
photo_url=image['content'], photo_width=300, photo_height=300,
thumb_url=image['content'])]
else:
return [InlineQueryResultArticle(
id=str(uuid.uuid4()), title='Error', description="Not Found",
input_message_content=InputTextMessageContent(message_text="Error\nNot Found", parse_mode="Markdown"),
thumb_url="http://siyanew.com/bots/custom.jpg")]
评论列表
文章目录