簡體   English   中英

確定某些文本在網站上的來源

[英]Determining where certain text comes from on website

我正在嘗試編寫一個 bash 腳本,該腳本從National Geographic下載當天的照片,將其設置為桌面背景,並將頁面上找到的圖片的描述放在桌面上的文本文件中。 (我知道有一些腳本可以做到這一點,但 NG 最近更改了他們的 POTD 頁面,它們不再起作用。)

我已經讓圖片下載並成為桌面背景,但我不知道如何下載圖片的完整描述(在網站圖片下方找到的那個,而不是標題中元數據中的較短版本)。 問題是,描述沒有出現在我的腳本使用curl (或wget )下載的頁面中。 但是,在瀏覽器中查看時它顯然存在。

如果描述文本不在 html 文件中,它來自哪里? 如何下載/解析描述,最好使用 bash 或 python?

謝謝你的幫助。

埋在該國家地理頁面的 html 中的是以下屬性:

data-platform-endpoint="http://www.nationalgeographic.com/photography/photo-of-the-day/_jcr_content/.gallery.2016-09.json"

您要查找的標題位於該 URL 指向的 JSON 文件中。 例如,在該 JSON 文件的今天版本中,我們發現:

"caption":"<p>A giraffe leads a herd of zebras as the animals stamede from a threat unseen. Your Shot photographer Mohammed AlNaser captured this image in Tanzania\u2019s Serengeti National Park. The zebras \u201cemerged from nowhere,\u201d AlNaser writes. \u201cThey were obviously drinking water and something scared them and created a few seconds of a chaos.\u201d<\/p>\n"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM