library/src/blockclass/BP-BlockClass.cc
/*
 * Blockparty Google Scraping Interface:
 * ------------------------------------------------
 * Allows for the extraction and storage of google search results.  This
 * requires a valid HTTP session to work.
 *
 */
Blockparty Google Scraping Interface.

Allows for the extraction and storage of google search results.  This
requires a valid HTTP session to work.
Blockparty Google Scraping Interface . Allows for the extraction and storage of google search results . This requires a valid HTTP session to work .
BP_ERROR_T Block::runGoogleSearch(char *query)
{
	if(!query)
		return ERR_FAILURE;
	P_BP_HTTP_SESSION http_session = this->httpSession;
	if (!http_session)
		return ERR_FAILURE;
	if (!this->google_session)
		this->google_session = BP_OpenNewGoogleSearch(query, http_session);
	if (this->custom_google_blacklist)
	{
		this->google_session->custom_blacklist = this->custom_google_blacklist;
		size_t i = 0;
		for (; this->custom_google_blacklist[i]; i++) {}
		this->google_session->custom_blacklist_count = i;
	}
	this->google_session->google_retry_on_too_small_size = this->google_retry_on_too_small_size;
	this->google_session->google_retry_on_bad_connect = 0;
	if(this->google_retry_on_bad_connect)
		this->google_session->google_retry_on_bad_connect = this->google_retry_on_bad_connect;
	curl_easy_setopt(this->google_session->http_session->curl, CURLOPT_FOLLOWLOCATION, 1);
	while
	(
		BP_RetrieveGoogleResult(this->google_session, this->secs_between_google_request) != ERR_FAILURE
	)
	{
		this->AddWarningToStack((char *) "\n [+] Retrieving result");
	}
	if (this->google_session->captcha_activated)
	{
		this->AddErrorToStack((char*) "\n Fatal: Google Search Captcha Activated");
		printf("\n [!!] Fatal: Google Search Captcha Activated");
		exit(0);
	}
	return ERR_SUCCESS;
}
BP_ERROR_T Block :: runGoogleSearch ( char * query ) { if ( ! query ) return ERR_FAILURE ; P_BP_HTTP_SESSION http_session = this -> httpSession ; if ( ! http_session ) return ERR_FAILURE ; if ( ! this -> google_session ) this -> google_session = BP_OpenNewGoogleSearch ( query , http_session ) ; if ( this -> custom_google_blacklist ) { this -> google_session -> custom_blacklist = this -> custom_google_blacklist ; size_t i = 0 ; for ( ; this -> custom_google_blacklist [ i ] ; i ++ ) { } this -> google_session -> custom_blacklist_count = i ; } this -> google_session -> google_retry_on_too_small_size = this -> google_retry_on_too_small_size ; this -> google_session -> google_retry_on_bad_connect = 0 ; if ( this -> google_retry_on_bad_connect ) this -> google_session -> google_retry_on_bad_connect = this -> google_retry_on_bad_connect ; curl_easy_setopt ( this -> google_session -> http_session -> curl , CURLOPT_FOLLOWLOCATION , 1 ) ; while ( BP_RetrieveGoogleResult ( this -> google_session , this -> secs_between_google_request ) != ERR_FAILURE ) { this -> AddWarningToStack ( ( char * ) " \n " ) ; } if ( this -> google_session -> captcha_activated ) { this -> AddErrorToStack ( ( char * ) " \n " ) ; printf ( " \n " ) ; exit ( 0 ) ; } return ERR_SUCCESS ; }
Blockparty Google Scraping Interface:
Blockparty Google Scraping Interface :
// ensure we have a query // set http session from local class session // open/setup query interface // set the custom blacklist in the class // set the list pointer in the google scraper structure // loop to get list entry count // set custom balcklist count // set the retry flag here // set the connect string to 0 // set reconnect flag from class member // set follow location to 1 (follows 302) // retrieve query results // add warning to the stack // return indicating success