library/src/blockclass/BP-BlockClass.cc
// Provide a buffer, and it will extract a full HTML structure
Provide a buffer, and it will extract a full HTML structure
Provide a buffer and it will extract a full HTML structure
P_BP_HTML_FULL_EXTRACTION Block::HtmlParse(char *url, bool saveBuffInClass)
{
	if (!this->httpSession)
		return NULL;
	if(!url)
		url = this->httpSession->lastRequestedHref;
	if(!url)
		return NULL;
	if(this->htmlExtraction)
	{
		this->HtmlDestroyExtraction();
		this->htmlExtraction = NULL;
	}
	this->htmlExtraction = HTMLDecodeBuffer
	(
			httpSession->page->page_data,
			httpSession->page->page_data_size,
			url,
			NULL,
			NULL,
			HTML_PARSE_NOERROR,
			NULL,
			this->httpSession
	);
	if (saveBuffInClass)
	{
		if(this->unparsedHtml)
		{
			tq_free(this->tq, this->unparsedHtml);
			this->unparsedHtml = NULL;
			this->unparsedHtmlLen = 0;
		}
		this->unparsedHtml    = tq_strndup(this->tq, httpSession->page->page_data, httpSession->page->page_data_size, BPLN);
		this->unparsedHtmlLen = httpSession->page->page_data_size;
	}
	return htmlExtraction;
}
P_BP_HTML_FULL_EXTRACTION Block :: HtmlParse ( char * url , bool saveBuffInClass ) { if ( ! this -> httpSession ) return NULL ; if ( ! url ) url = this -> httpSession -> lastRequestedHref ; if ( ! url ) return NULL ; if ( this -> htmlExtraction ) { this -> HtmlDestroyExtraction ( ) ; this -> htmlExtraction = NULL ; } this -> htmlExtraction = HTMLDecodeBuffer ( httpSession -> page -> page_data , httpSession -> page -> page_data_size , url , NULL , NULL , HTML_PARSE_NOERROR , NULL , this -> httpSession ) ; if ( saveBuffInClass ) { if ( this -> unparsedHtml ) { tq_free ( this -> tq , this -> unparsedHtml ) ; this -> unparsedHtml = NULL ; this -> unparsedHtmlLen = 0 ; } this -> unparsedHtml = tq_strndup ( this -> tq , httpSession -> page -> page_data , httpSession -> page -> page_data_size , BPLN ) ; this -> unparsedHtmlLen = httpSession -> page -> page_data_size ; } return htmlExtraction ; }
Provide a buffer, and it will extract a full HTML structure
Provide a buffer and it will extract a full HTML structure
// http session is required for a parse // if there is no url, set url as last requested href // if we still have no url, return false // create html extraction (null last pointer creates its own garbage collector) // if the user has specified that they want to save the buffer, // duplicate it here and set the size. // destroy unparsed data first // now set it // return the fully parsed html