答案 0 :(得分:5)
您可能想要查看给定页面是否以JSON格式提供输出。然后你可以简单地请求值而不是搞乱HTML。雅虎!财务网站甚至可以提供可用于轻松请求价值的API。
答案 1 :(得分:0)
如果你想搞乱HTML代码:
#include <iostream>
#include <fstream>
int main() {
std::ifstream ifile("in.html");
std::string line;
std::string ndl("<span id=\"yfs_l10_sgdmyr=x\">");
while(ifile.good()){
getline(ifile, line);
if (line.size()) {
size_t spos, epos;
if ((spos = line.find(ndl)) != std::string::npos) {
spos += ndl.size();
if ((epos = line.find(std::string("</span>"), spos)) != std::string::npos) {
std::cout << line.substr(spos, epos-spos) << std::endl;
}
}
}
}
return 0;
}