Advertisement
Riremito

html parser/Main.cpp

Apr 14th, 2017
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2. #include"brynhildr.h"
  3. #include"html.h"
  4.  
  5. void main(){
  6.     Brynhildr br("http://otthts.blog.fc2.com/");//ドメイン(リファラと相対パスに使用)
  7.     br.Access("http://otthts.blog.fc2.com/");//アクセスするページ
  8.     br.Convert();//UTFからSJISに変換
  9.  
  10.     char *html = br.Get();//文字列を取得
  11.     HTMLParser hp(html);//htmlを解析
  12.     HTMLTag *ht;
  13.     int i = 0;
  14.     char href[0x100];
  15.  
  16.     do{
  17.     ht = hp.Find("div id=\"rthread\"->a", i++);
  18.     if(ht){
  19.         ht->Get("href", href);
  20.         printf("%s\n%s\n", ht->GetText(), href);
  21.     }
  22.     }while(ht);
  23.  
  24.     hp.ShowTree();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement