Read HTML content
I want to develop an app for Sailfish and I need to read some data from a website. What do I use for writing a simple crawler?
I'm reading my website using QNetworkRequest. But I don't know what to use to parse the HTML. This is what I have now:
void CCrawler::replyFinished(QNetworkReply* pReply) {
QByteArray data = pReply->readAll();
QString str(data);
//QWebPage page;
QWebFrame *frame = new QWebFrame();
frame->mainFrame()->setHtml(str);
QWebElement document = frame->documentElement();
QWebElementCollection elements = document.findAll("a");
foreach (QWebElement element, elements)
qDebug() << element.toInnerXml();
}
But I get an error:
invalid use of incomplete type class QWebFrame
I have made app for reading my countries currency information, it's written in python, this is how i read HTML
I could not post this like code, how to do that?
url = "https://www.nbg.gov.ge/index.php?m=582" html_page = urllib2.urlopen(url) soup = BeautifulSoup(html_page) table = soup.find("table", border="0", style="width:100%;")
cur = [] usd = [] pas = [] aiw = [] nishani = ""
for row in table.findAll('tr')[1:]: col = row.findAll('td') cur.append(col[0])
for line in cur[2].findAll('tr'): usd.append(line) pas.append(line.text)
for line in cur[2].findAll('img'): aiw.append(line)
notify = pas[-3] raodenoba = str(notify[21:])
AnonUser10082 ( 2016-12-19 10:23:56 +0200 )editThanks, but I already have a crawler in Python for this. I just want to do the same with c++.
alko89 ( 2016-12-19 11:31:56 +0200 )edithey..can this kind of a crawler crawl how-to pages like those at knowhownonprofit.org??
hivy ( 2017-07-28 12:33:07 +0200 )edit