如何在此处抓取javascript变量的数据?

问题描述 投票:-1回答:1

这是网站https://edge.pse.com.ph/companyPage/stockData.do?cmpy_id=630的链接

我想在这里获取数据:

enter image description here

我可以用Google Sheet或python报废吗?

javascript screen-scraping
1个回答
0
投票

这在Node中有效。它是使用邮递员程序生成的。

const https = require('https');
const options = {
  method: 'POST',
  hostname: 'edge.pse.com.ph',
  path: '/common/DisclosureCht.ax?Host=%20edge.pse.com.ph&Connection=%20keep-alive&Content-Length=%2085&Accept=%20application%2Fjson%2C%20text%2Fjavascript%2C%20*%5C%2F*%3B%20q%3D0.01&X-Requested-With=%20XMLHttpRequest&User-Agent=%20Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F81.0.4044.138%20Safari%2F537.36&Content-Type=%20application%2Fjson&Origin=%20https%3A%2F%2Fedge.pse.com.ph&Sec-Fetch-Site=%20same-origin&Sec-Fetch-Mode=%20cors&Sec-Fetch-Dest=%20empty&Referer=%20https%3A%2F%2Fedge.pse.com.ph%2FcompanyPage%2FstockData.do%3Fcmpy_id%3D630&Accept-Encoding=%20gzip%2C%20deflate%2C%20br&Accept-Language=%20en-US%2Cen%3Bq%3D0.9',
  headers: { 'Content-Type': 'application/json' }
};
const req = https.request(options, res => {
  const chunks = [];
  res.on('data', chunk => chunks.push(chunk));
  res.on('end', chunk => console.log(Buffer.concat(chunks).toString()));
  res.on('error', error => console.error(error));
});
const postData = JSON.stringify({
  cmpy_id: 630,
  security_id: 569,
  startDate: '06-13-2019',
  endDate: '06-13-2020'
});
req.write(postData);
req.end();
© www.soinside.com 2019 - 2024. All rights reserved.