python - 如何在 TradingView 中使用 python 请求生成警报?
问题描述
我一直在尝试在 TradingView 上创建警报并且很挣扎。首先,我正在登录 TradingView。之后,我创建了一个警报,但此时我收到了 <Response [400]>。
我在哪里做错了。
import requests
from requests.auth import HTTPBasicAuth
url = "https://pine-facade.tradingview.com/pine-facade/gen_alert/?user_name=*******"
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
'origin': 'https://tr.tradingview.com'
}
data = {
'alert_info': '{"version":21,"condition":{"id":"cross","fireInfo":{"frequency":"on_first_fire"},"mainSeries":{"id":"-273720050"},"alertSeries":{"id":"-273720050"},"band":{"id":"4iHylo"}},"statesForAlert":{"-273720050":{"id":"-273720050","uniqueId":"-273720050","type":"MainSeries","proSymbol":"BIST:XU100","actualSymbol":"BIST_DLY:XU100","symbolString":"={\"symbol\":\"BIST_DLY:XU100\",\"adjustment\":\"splits\"}","interval":"1D","style":1,"styleInputs":{},"extendedHours":false,"dividendsAdjustment":false,"isSpread":false,"formatter":{"type":"price","state":{"fractional":false,"fractionalLength":2,"minMove":1,"minMove2":0,"priceScale":100}}},"4iHylo":{"id":"4iHylo","uniqueId":"4iHylo","type":"Value","value":"1441.3"}},"message":"BU BİR DENEMEDİR"}'
}
login_header = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
'origin': 'https://tr.tradingview.com',
'referer': 'https://tr.tradingview.com/chart/UBleIH5q/'
}
login_url = "https://tr.tradingview.com/accounts/signin/"
login_data = {
'username': '****',
'password': '*****',
'remember': 'off'
}
with requests.Session() as s:
y = s.post(login_url, data=login_data, headers=login_header)
print(y)
response = s.post(url, data=data, headers=headers)
print(response)
解决方案
推荐阅读
- google-chrome - 在新的网络浏览器中使用 Google 的反向工程建议 API 是否违法?
- c# - 我可以锁定 Console.Out 以防止乱码文本输出吗?
- java - spring webflux CORS 标头被删除
- animation - 有没有办法开发这样的网站(https://slackdemo.com)?
- javascript - ASP.net Core 2.1 中的 Knockout js 返回未定义?
- c# - 如何在 WCF REST C# 中进行异常处理
- python - 如何修复缩进错误?当我要填充颜色时
- c# - 不应用对 IActionFilter 中的响应对象所做的更改
- python-3.x - 如何用scrapy保存图片
- postgresql - 如何在 postgresql 中创建考勤表?