2016-09-19 11 views
0

OneNote API에서 OneNote 태그 (예 : data-tag='to-do')를 검색 또는 필터와 함께 사용할 수 있습니까? 나는 통신 수를 사용하는 것을 시도하고 그러나 아무 성공도 찾아 냈다. onenote API에서 "data-tag = '할 일' '을 검색하거나 필터링 할 수 있습니까? 그렇다면 우리가 어떻게 할 수 있습니까?

나는이 방법으로 시도 -

$url = "https://www.onenote.com/api/v1.0/me/notes"; 
    //$url .= "/pages?search=hello"; 
    $url .= "/pages?filter=data-tag eq 'to-do'"; 

내가 데이터 태그를 검색 한 후 '할 일'데이터 태그 =이 포함되어 OneNote의 페이지에서 데이터를 추출하고 싶습니다.

도움을 주시면 감사하겠습니다.

답변

0

모든 페이지를 실행해야합니다.

각 페이지의 경우, 당신은 당신이 구문 분석 할 수있는 문자열을 얻을 거기에서 https://www.onenote.com/api/v1.0/me/notes/pages/%s/content?includeIds=true

GET 호출로 컨텐츠를 검색 할 수 있습니다.

jsoup을 사용하시기 바랍니다.

Document doc = Jsoup.parse(content); 
Elements todos=doc.select("[data-tag^=\"to-do\"]"); 

for(Element todo:todos) { 
    System.out.println(todo.ownText()); 
    } 
0

슬프게도 OneNote의 API는 아직 지원하지 않는, 그래서 데이터 -로 메모를 추출 내 사용자 지정 파서를 작성했습니다 : 당신이 다음 쓸 수 jsoup와

(content 가정이 페이지의 내용을 포함) 태그를 포함 할 수 있습니다. 여기있다 :이 같은 다른 태그를 추출 할 수 있습니다 또한

OneNoteParser.ExtractTaggedNotes(pageContent, "to-do"); 

:

public class OneNoteParser 
    { 
     static public List<Note> ExtractTaggedNotes(string pageContent, string tag = "*") 
     { 
      List<Note> allNotes = new List<Note>(); 

      string[] dataTagString = { "data-tag=\""}; 

      string[] dirtyNotes = pageContent.Split(dataTagString, StringSplitOptions.RemoveEmptyEntries); 

      //First one in this array can be dropped as it doesn't contain todo 
      for (int i = 1; i < dirtyNotes.Length; i ) 
      { 
       string curStr = dirtyNotes[i]; 
       Note curNote = new Note(); 

       // Firstly we need to extract all the tags from it (sample html: data-tag="to-do:completed,important" ....) 
       string allTags = curStr.Substring(0,curStr.IndexOf("\"")); 

       curNote.Tags = new List<string>(allTags.Split(',')); 

       // Now we have to jump to the next ">" symbol and start finding the text after it 
       curStr = curStr.Substring(curStr.IndexOf(">")); 

       int depth = 1; 
       bool addAllowed = false; 

       for (int j = 0; j < curStr.Length - 1; j ) 
       { 
        // Finding next tag opener "<" symbol 
        if (curStr[j] == '<') 
        { 
         addAllowed = false; 

         // Checking if it is not "</" closer 
         if (curStr[j 1] == '/') 
         { 
          // Means this is a tag closer. Decreasing depth 
          depth--; 
         } 
         else 
         { 
          // Means this is an tag opener. Increasing depth 
          depth ; 
         } 
        } 
        else if (curStr[j] == '>') 
        { 
         addAllowed = true; 

         if (j > 0 && curStr[j - 1] == '/') 
         { 
          // Means this is a tag closer. Decreasing depth 
          depth--; 
         } 
        } 
        else 
        { 
         if (depth < 1) 
         { 
          // Found end of the tag. Saving index and exiting for loop 
          break; 
         } 

         if (addAllowed) 
          curNote.Text = curStr[j]; // Appending letter to string 
        } 
       } 

       // Filtering by tag and adding to final list 
       if (tag == "*" || curNote.Tags.Any(str => str.Contains(tag)))//curNote.Tags.Contains(tag, StringComparer.CurrentCultureIgnoreCase)) 
         allNotes.Add(curNote); 

      } 
      return allNotes; 
     } 
    } 

그리고 여기 Note

public class Note 
    { 
     public string Text; 
     public List<string> Tags; 
     public Note() 
     { 
      Tags = new List<string>(); 
     } 
    } 

추출하는 클래스입니다 잭에게-S 단순히이 함수를 호출 :

OneNoteParser.ExtractTaggedNotes(pageContent, "important"); 
OneNoteParser.ExtractTaggedNotes(pageContent, "highlight"); 
//...