Пример #1
0
bool autobots_toutiao::GetPostId(const QByteArray& arr)
{
  HtmlParseUtils html_parse(arr.data(), arr.length());

  // "查找post_from_id"
  GumboNode* node = html_parse.FirstElementNode("name", "post_form_id");

  if (node != NULL)
  {
    std::string post_from_id = HtmlParseUtils::GetAttributeValue(node, "value");

    QString str = QString::fromStdString(post_from_id);

    m_post_id = str;
  }

  // "查找client_id"
  node = html_parse.FirstElementNode("name", "client_id");

  if (node != NULL)
  {
    std::string client_id = HtmlParseUtils::GetAttributeValue(node, "value");

    m_client_id = QString::fromStdString(client_id);
  }

  if (m_post_id.isEmpty() || m_client_id.isEmpty())
  {
    return false;
  }

  return true;
}
Пример #2
0
int sslvpn_rewrite(enum __sslvpn_rewrite_type__ type,
	const char * string,int length,char * output, int size,const char* path)
{
	CSSParser * csp ;
	JSParser  * jsp ;
	HTMLParser* hp  ;
	int ret = -1 ;

	switch(type)
	{
		case SSLVPN_RW_CSS:
			csp = css_parser_new();
			csp->scanner->string = csp->rewriter->string = (u8*)string;
			csp->scanner->length = csp->rewriter->length = (u32)length;
			csp->rewriter->path  = (u8*)path;
			if( css_parse(csp,CPM_FILE) )
			{
				ret = 0 ;
				finalStringOutput(csp->rewriter->rw_token,(u8*)string,(u32)length,output,size);
			}
			css_parser_free(csp);
			break;
		case SSLVPN_RW_XML:
		case SSLVPN_RW_HTML:
			hp = html_parser_new((u8*)string,(u32)length);
			hp->rewriter->path  = (u8*)path;
			if( html_parse(hp) )
			{
				ret = 0 ;
				finalStringOutput(hp->rewriter->rw_token,(u8*)string,(u32)length,output,size);
			}
			html_parser_free(hp);
			break;
		case SSLVPN_RW_JAVA:
			jsp = js_parser_new();
			jsp->scanner->string = jsp->rewriter->string = (u8*)string ;
			jsp->scanner->length = jsp->rewriter->length = (u32)length ;
			jsp->rewriter->path  = (u8*)path;
			parse(jsp,JSS_NONE);

			ret = 0 ;
			finalStringOutput(jsp->rewriter->rw_token,(u8*)string,(u32)length,output,size);

			js_parser_free(jsp);
		case SSLVPN_RW_ERROR:
		default:break;
	}

	return ret;
}
Пример #3
0
bool autobots_toutiao::GetCsrfToken(const QByteArray& rp_data)
{
  HtmlParseUtils html_parse(rp_data.data(), rp_data.length());

  // "查找csrftoken"
  GumboNode*  node = html_parse.FirstElementNode("name", "csrfmiddlewaretoken");

  if (node != NULL)
  {
    std::string csrf_token = HtmlParseUtils::GetAttributeValue(node, "value");
    m_csrf_token = QString::fromStdString(csrf_token);
    return true;
  }

  return false;
}
Пример #4
0
void HtmlParser::parse(const std::string& html)
{
  //read the html code - each tag will be one field in std::vector
  YY_BUFFER_STATE bp;

#if defined YYDEBUG && YYDEBUG==1
  html_debug=0;
#endif

  yyscan_t scanner;
  html_lex_init_extra(htmlCode, &scanner);

  bp=html__scan_string(html.data(), scanner);
  html__switch_to_buffer(bp, scanner);
  html_parse(htmlCode, scanner);

  html__delete_buffer(bp, scanner);
  html_lex_destroy(scanner);

  //display data
  for ( const HtmlTag &i: htmlCode->getHtmlTags())
    std::cout << i << std::endl;
}
Пример #5
0
int
html_load_memory(struct html_output *output, const struct array data)
{
	return html_parse(output, data);
}