2017-07-22 31 views
1

幫助捲曲試圖獲得內容,但捕捉負載頁

https://workflowy.com/s/CbqM.M3tcZFhqd3#/?q=ADM-NF01

我試圖捕捉

功能指南 V0 - 阿爾法 基本A11Y和I18N 基金會可訪問性和國際化 ADM -NF01

但我似乎要捕獲的是加載屏幕

捕獲= time (curl -s -G -L --connect-timeout 100 https://workflowy.com/s/CbqM.M3tcZFhqd3#/?q=ADM-NF01)

只有在這條線V0真正感興趣 - 阿爾法捕捉到了這個能夠改變(版本)我會船到橋頭時,我得到這個位工作。

是有辦法做到這一點試着捲曲和wget,但沒有運氣

主要目的是搜索,即ADM-NF01和搶V0 - 阿爾法

這裏有一些例子 https://workflowy.com/s/CbqM.M3tcZFhqd3#/?q=DV-F85 DV- F85 = Vn的 - 未來

https://workflowy.com/s/CbqM.M3tcZFhqd3#/?q=ADM-F71.1 ADM-F71.1 = V1 - 貝塔

我不知道從哪裏開始捆綁google搜索某人suggeste d JSON解析,但知道如何做到這一點,因爲我甚至不能得到數據?

感謝

回答

0

從網絡日誌,你必須在JSON內容可供選擇:

https://workflowy.com/get_initialization_data?share_id=CbqM.M3tcZFhqd3&client_version=18

,你可以用jq JSON解析器解析到一個特定領域應用進行過濾,並且預期輸出:

filter="ADM-NF01" 

curl -s "https://workflowy.com/get_initialization_data?share_id=CbqM.M3tcZFhqd3&client_version=18" | \ 
jq -r --arg filter $filter '.projectTreeData.mainProjectTreeInfo | 
     .rootProject.nm as $h1 | 
     .rootProjectChildren[] | 
     .nm as $h2 | 
     .ch[] | 
     .nm as $h3 | .no as $h4 | 
     select(.ch != null) | 
     .ch[] | select(.nm == $filter) | $h1,$h2,$h3,$h4,.nm' 

其給出:

Feature Roadmap 
V0 - Alpha 
Basic A11Y and I18N 
Foundations for Accessibility and Internationalisation 
ADM-NF01 

對於JQ部分:

  • --arg用於通過過濾器值
  • 你想保留存儲在變量與as $var
  • select用於應用過濾器的領域

主要目標是搜索f或即ADM-NF01和搶V0 - 阿爾法

如果你只需要V0 - Alpha部分:

filter="ADM-NF01" 

data=$(curl -s "https://workflowy.com/get_initialization_data?share_id=CbqM.M3tcZFhqd3&client_version=18" | \ 
jq -r --arg filter $filter '.projectTreeData.mainProjectTreeInfo | 
     .rootProjectChildren[] | .nm as $h2 | 
     .ch[] | select(.ch != null) | 
     .ch[] | select(.nm == $filter) | $h2') 

echo "$data" 

注意==是精確匹配,如果需要包含可用於:

select(.nm | contains($filter)) 
+0

謝謝不知道如何使用$ var位? echo「$ h2」什麼也沒有顯示 – user1184628

+0

'$ h2' var是jq內部的,你不能在外面使用它。我已經更新了答案,得到的結果在外部變量 –

+0

似乎並沒有找到所有IDS – user1184628