gpt4 book ai didi

python - 将新 URL 解析为 IFTTT

转载 作者:行者123 更新时间:2023-12-01 08:34:23 25 4
gpt4 key购买 nike

IFTTT 中的 RSS 阅读器不喜欢 https://rss.art19.com/the-daily。我正在使用 python 提取一个新链接,并将其安排在每天早上 06:30。然而,我发现将新的 url 解析到 IFTTT 小程序中非常困难。我正在使用 glitch.com 来组合事件。

重点是在我的 Sonos 设置上于 06:30 自动播放此播客。

import schedule
import time
from bs4 import BeautifulSoup
import requests


def job():
url = 'https://rss.art19.com/the-daily'
request = requests.get(url)
respose = request.content.decode('utf-8')
soup = BeautifulSoup(respose, 'lxml')

link = soup.find_all('enclosure')[0]

a = str(link).split(' ')[3]
x = slice(a)
y = str(x).split('"')[1]

print(y)



# def notification(message):
# report = {}
# report[“value1”] = message
# requests.post('https://maker.ifttt.com/trigger/play_sonos/with/key/KEY", data=report')

# notification(number)

schedule.every().day.at("06:30").do(job,'It is 06:30am')
print('\n')
print(' Got it')

while True:
schedule.run_pending()
time.sleep(60)

最佳答案

我最终使用了 SOCO 库。

from soco import SoCo
import schedule
import time
from bs4 import BeautifulSoup
import requests

#Play5
five_son = SoCo('PLAYER_IP')

#Play5(Office)
five_office_son = SoCo('PLAYER_IP')

#Play3
three_son = SoCo('PLAYER_IP')
print( 'Players are Active! ')
print('\n')


def get():
url = 'https://rss.art19.com/the-daily'
request = requests.get(url)
respose = request.content.decode('utf-8')
soup = BeautifulSoup(respose, 'lxml')

link = soup.find_all('enclosure')[0]

a = str(link).split(' ')[3]
x = slice(a)
y = str(x).split('"')[1]

return y

def job():
sonos = five_office_son.partymode()
sonos.play_uri(get())

track = sonos.get_current_track_info()

print(track)

sonos.pause()
sonos.play()


schedule.every().monday.at("06:30").do(job,'It is 06:30am')
schedule.every().tuesday.at("06:30").do(job,'It is 06:30am')
schedule.every().wednesday.at("06:30").do(job,'It is 06:30am')
schedule.every().thursday.at("06:30").do(job,'It is 06:30am')
schedule.every().friday.at("06:30").do(job,'It is 06:30am')
print('\n')
print('Got it')

while True:
schedule.run_pending()
time.sleep(60)

关于python - 将新 URL 解析为 IFTTT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53797523/

25 4 0
文章推荐: asp.net - 如何在 ASPX 标记中调用模块函数?
文章推荐: jsp - 使用从 Servlet 中的数据库获取的值填充 JSP 中的 HTML