Skip to content

Instantly share code, notes, and snippets.

@CarterTsai
Created November 14, 2019 15:52
Show Gist options
  • Save CarterTsai/10f569e1e683b0f730d4aff13f1878d1 to your computer and use it in GitHub Desktop.
Save CarterTsai/10f569e1e683b0f730d4aff13f1878d1 to your computer and use it in GitHub Desktop.
taigo 取得Yahoo熱門股票並且搜尋
const { closeBrowser, openBrowser, goto, write, click, $, into} = require('taiko');
(async () => {
try {
await openBrowser();
await goto("https://tw.stock.yahoo.com/");
// 取得熱門個股第一個股票編號, 並且搜尋
var hotStockNumber = await evaluate($('#ystkhotb th a > span'), (elem) => {return elem.innerText});
await write(hotStockNumber, into($("#stock_id")));
await press('Enter');
} catch (error) {
console.error(error);
} finally {
closeBrowser();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment