Answer the question
In order to leave comments, you need to log in
When you open the created link in Yandex, on the iPhone, instead of spaces,% 20 is filled, but on the android it is normal. What is the problem and how to solve it?
async def process_callback_button1(callback_query: types.CallbackQuery):
genre = callback_query.data
random_film = handlers.films(genre)
await bot.answer_callback_query(callback_query.id)
await bot.send_message(callback_query.from_user.id, f"{search}", reply_markup=InlineKeyboardMarkup().add(
InlineKeyboardButton(text=f'{random_film}',
url=f'https://yandex.ru/search/?text={random_film}')))
def films(genre):
with open('films_genre_dict.json', encoding='utf-8') as f:
dict_films = json.load(f)
s = random.choice(dict_films[f'{genre}'])
return f'{s[0]} {s[1]}'
Answer the question
In order to leave comments, you need to log in
As correctly said above, this is called URL Encoding. Encode your text in advance yourself, then everything will be fine.
import urllib.parse
def films(genre):
with open('films_genre_dict.json', encoding='utf-8') as f:
dict_films = json.load(f)
s = random.choice(dict_films[f'{genre}'])
return urllib.parse.quote(f'{s[0]} {s[1]}')
f'{genre}'
f"{search}"
f'{random_film}'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question