请求协助:Chartink筛选器股票列表无法导入Google Sheet
Chartink筛选器股票列表导入Google Sheet失败求助
问题详情
尝试将Chartink筛选器的股票列表导入Google Sheet,但未能成功,以下是具体配置和已编写的代码:
单元格配置
- A1单元格:
https://chartink.com/screener/macd-cross-51432 - B1单元格:
(+{cash}+(+latest+macd+line(+26+,+12+,+9+)+>+latest+macd+signal(+26+,+12+,+9+)+and+1+day+ago++macd+line(+26+,+12+,+9+)+<=+1+day+ago++macd+signal(+26+,+12+,+9+)+and+latest+close+<=+300+and+latest+rsi(+14+)+>+70+)+)+ - C1单元格:
groupcount(+1+where+daily+macd+line(+26+,+12+,+9+)+>+daily+macd+signal(+26+,+12+,+9+)+and+1+day+ago++macd+line(+26+,+12+,+9+)+<=+1+day+ago++macd+signal(+26+,+12+,+9+)),groupcount(+1+where+daily+close+<=+300),groupcount(+1+where+daily+rsi(+14+)+>+70)
已编写的Google Apps Script代码
function Chartinkupload() { // Get the URL, scan_clause, and debug_clause from specific cells const url = SpreadsheetApp.getActiveSheet().getRange("A1").getValue(); const scanClause = SpreadsheetApp.getActiveSheet().getRange("B1").getValue(); const debugClause = SpreadsheetApp.getActiveSheet().getRange("C1").getValue(); // Prepare the payload data const payloadData = { "scan_clause": scanClause, "debug_clause": debugClause }; // Convert payload to JSON string const payload = JSON.stringify(payloadData); try { // Send POST request with JSON payload and muteHttpExceptions option const response = UrlFetchApp.fetch(url, { method: "POST", payload: payload, contentType: "application/json", muteHttpExceptions: true // Added option to mute HTTP exceptions }); // Check for successful response if (response.getResponseCode() === 200) { const json = response.getContentText(); const chartinkData = JSON.parse(json); // Write data to the "chartink" sheet starting from cell A1 const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("chartink"); sheet.clear(); // Clear existing data sheet.getRange(1, 1).setValue(json); // Write JSON response to cell A1 Logger.log("Data written to sheet 'chartink'"); } else { Logger.log("Error fetching data: " + response.getResponseCode()); } } catch (error) { Logger.log("Error during upload: " + error.message); } }
期望结果
希望在Google Sheet的chartink工作表中获取结构化的股票数据,表头如下:序号 股票名称 代码 链接 涨跌幅(%) 价格 成交量
内容的提问来源于stack exchange,提问作者Afroz Alam
相关产品推荐
相关产品推荐

