Exemplo n.º 1
0
vector<string> get_math(Page& page) {
    cout << "This page is: ";
    if (isXHTML(page))
        cout << "XHTML" << endl;
    else if (isHTML(page))
        cout << "HTML" << endl;

    if (isXHTML(page))
        return get_math_xhtml(page.getContent(), page.getUrl());
    else if (isHTML(page))
        return get_math_html(page);
    else {
        cout << ">>> Skipping link (not XHTML nor HTML).\n";
        vector<string> emptyVector;
        return emptyVector;
    }
}
Exemplo n.º 2
0
bool RSSFeedParser::parseRSSFeed(const string &source, DocStream &doc_stream) {
	Node root(source);
	if (! root){
		return false;
	}
	root.setSelfDestroy();

	Node node_channel = root.findElement(root, "channel", "", "", Node::DESCEND);
	if (! node_channel){
		return false;
	}

	string channel_name;
	Node n = node_channel.findElement(node_channel, "title", "", "", Node::DESCEND_FIRST);
	if (n){
		channel_name = n.getInnerText();
	}

	Node node_item = node_channel.findElement(node_channel, "item", "", "", Node::DESCEND_FIRST);
	while (node_item){
		Document doc;

		n = node_item.findElement(node_item, "guid", "", "", Node::DESCEND_FIRST);
		if (n) {
			doc.doc_id = n.getInnerText();
		}
		if (! doc.doc_id.empty()) {
			doc.source = getId();

			n = node_item.findElement(node_item, "title", "", "", Node::DESCEND_FIRST);
			if (n) {
				doc.title = n.getInnerText();
			}

			n = node_item.findElement(node_item, "title", "", "", Node::DESCEND_FIRST);
			if (n) {
				doc.title = n.getInnerText();
			}

			n = node_item.findElement(node_item, "description", "", "", Node::DESCEND_FIRST);
			if (n) {
				string summary = n.getInnerText();
				if (isHTML(summary)) {
					doc.summary = stripHTML(summary);
					doc.formatted_summary = summary;
				}
				else {
					doc.summary = summary;
				}
			}

			n = node_item.findElement(node_item, "link", "", "", Node::DESCEND_FIRST);
			if (n) {
				doc.url = n.getInnerText();
			}

			n = node_item.findElement(node_item, "pubDate", "", "", Node::DESCEND_FIRST);
			if (n) {
				string date_str = n.getInnerText();
				posix_time::ptime t = util::stringToTime(date_str, util::internet_time_format);
				doc.date = util::to_time_t(t);
			}

			doc_stream.addDoc(doc);
		}

		node_item = node_channel.findElement(node_item, "item", "", "", Node::NO_DESCEND);
	}

	return true;
}
Exemplo n.º 3
0
WebURL WebNotification::iconURL() const
{
    ASSERT(!isHTML());
    return m_private->iconURL();
}
Exemplo n.º 4
0
WebString WebNotification::body() const
{
    ASSERT(!isHTML());
    return m_private->contents().body();
}
Exemplo n.º 5
0
WebURL WebNotification::url() const
{
    ASSERT(isHTML());
    return m_private->url();
}