msg.reply_markup.rows[0].buttons[0].url
import re
msg = '''[Message(id=899, peer_id=PeerUser(user_id=7415649360), date=datetime.datetime(2021, 8, 10, 9, 52, 37, tzinfo=datetime.timezone.utc), message='⚠️ WARNING: The following is a third party advertisement. Do not trust anything that promises to make you money. Use the following website at your own risk.\n--------------------- \n\nFree 100 OZC, price listing $30/OZC \n\nStart in 15/07/2021: Free 100 OZC, price listing $30/OZC \n \n--------------------- \nPress the "Visit website" button to earn LTC.\nYou will be redirected to a third party site.', out=False, mentioned=False, media_unread=False, silent=False, post=False, from_scheduled=False, legacy=False, edit_hide=False, pinned=False, from_id=None, fwd_from=None, via_bot_id=None, reply_to=None, media=None, reply_markup=ReplyInlineMarkup(rows=[KeyboardButtonRow(buttons=[KeyboardButtonUrl(text=' Go to website', url='https://doge.click/visit/Ka1gfo')]), KeyboardButtonRow(buttons=[KeyboardButtonCallback(text=' Report', data=b'{"name":"ReportClick","id":"click_tasks61124bf44b4413.68559229"}', requires_password=False), KeyboardButtonCallback(text='⏩ Skip', data=b'{"name":"SkipClick","id":"click_tasks61124bf44b4413.68559229"}', requires_password=False)])]), entities=[MessageEntityItalic(offset=0, length=156), MessageEntityItalic(offset=157, length=21), MessageEntityBold(offset=182, length=35), MessageEntityItalic(offset=283, length=21), MessageEntityItalic(offset=307, length=45), MessageEntityItalic(offset=353, length=45)], views=None, forwards=None, replies=None, edit_date=None, post_author=None, grouped_id=None, restriction_reason=[], ttl_period=None), total=57]'''
print(re.search(r'(https://.+?)\'', msg).group(1))
Этот метод можно вызвать с ключом доступа пользователя.
https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1666&api_key=DEMO_KEY
const responseJson = pm.response.json();
var cameras = [];
responseJson["photos"].forEach(function (photo) {
var name = photo["camera"]["name"];
if (!cameras.includes(name)) {
cameras.push(name);
}
});
console.log("Total photos:", responseJson["photos"].length);
console.log("Cameras:", cameras);
https://api.nasa.gov/mars-photos/api/v1/manifests/Curiosity?api_key=DEMO_KEY
const responseJson = pm.response.json();
const sol = 1666;
responseJson["photo_manifest"]["photos"].forEach(function(photo) {
if (photo["sol"] == sol) {
console.log(photo);
return
}
})
Найти снимок с id 268034 сделанный ровером Opportunity на панорамную камеру в первый сол
const responseJson = pm.response.json();
const photoId = 268034;
responseJson["photos"].forEach(function(photo) {
if (photo["id"] == photoId) {
console.log(photo);
return
}
})
%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0,+%D0%A2%D0%B2%D0%B5%D1%80%D1%81%D0%BA%D0%B0%D1
и есть кодировка. Это абсолютно валидный синтаксис.И requests, как не удивительно, выдаёт ошибку:
import requests
import webbrowser
from urllib.parse import urlencode
APP_ID =
API_KEY = ''
REDIRECT_URI = 'http://127.0.0.1:8000'
SCOPE = 'oauth-user-show oauth-donation-index'
# 2. Authorization Request
data = {'client_id': APP_ID, 'redirect_uri': REDIRECT_URI, 'response_type': 'code', 'scope': SCOPE}
url = 'https://www.donationalerts.com/oauth/authorize?' + urlencode(data)
webbrowser.open(url)
code = input('code: ')
# 4. Getting Access Token
data = {'grant_type':'authorization_code', 'client_id':APP_ID, 'client_secret': API_KEY, 'redirect_uri': REDIRECT_URI, 'code': code}
r = requests.post('https://www.donationalerts.com/oauth/token', data=data).json()
access_token = r['access_token']
refresh_token = r['refresh_token']
# Authorized Request
headers = {'Authorization': 'Bearer {}'.format(access_token)}
response = requests.get('https://www.donationalerts.com/api/v1/alerts/donations', headers=headers)
r = response.json()
print(r)
from datetime import datetime, timedelta
today = datetime.now().strftime('%Y-%m-%d')
from datetime import datetime, timedelta
today_date = datetime.now()
link = "https://api.rasp.yandex.net/v3.0/schedule/?apikey=f3a6c277-5bcc-48d9-95ed-6373ba1b6fa5&station=s2014001&transport_types=train&direction=departure&date=2021-01-18"
r = requests.get(link)
trains = json.loads(r.text)
for train in trains["schedule"]:
date, tz = train['departure'].split('+')
date = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S')
tz = datetime.strptime(tz, '%H:%M')
date = date + timedelta(hours=tz.hour)
if date < today_date:
print('Поезд ушел')
print(f"Станция: {trains['station']['title']}")
print(f"Отправка в {train['departure']}")
print(f"Номер поезда: {train['thread']['number']}")
print(f"Направление: {train['thread']['title']}\n")
Уже 2 день пытаюсь пофиксить
414 Request-URI Too Long
result=requests.post('https://api.vk.com/method/photos.saveWallPhoto', data={
'access_token':token,
'group_id':GROUP_ID,
'server':upload_response['server'],
'photo':upload_response['photo'],
'hash':upload_response['hash'],
'v':ver,}).json()
import requests
url = 'https://cb-api.ozonru.me/v2/finance/transaction/list'
headers = {'client-id': '836', 'api-key': '0296d4f2-70a1-4c09-b507-904fd05567b9'}
data ={"filter": {
"date": {
"from": "2020-10-01T07:14:11.897Z",
"to": "2020-10-31T07:14:11.897Z"
},
"transaction_type": "all"
},
"page": "1",
"page_size": "10"
}
r = requests.post(url, json=data, headers=headers)