0

我正在wget编写一个网页 src 代码,然后使用pup它来获取<meta>我需要的标签。现在我只想打印该content字段的值。

在这种情况下,我想要的输出是:https://example.com/my/folder/first.jpg?foo=bar

# wget page to /tmp/output.html
IMAGE_URL=$(cat /tmp/output.html | pup 'meta[property*="og:image"]')
echo $IMAGE_URL is:
<meta property="og:image" content="https://example.com/my/folder/first.jpg?foo=bar">
4

1 回答 1

0
wget -O /tmp/output.html --user-agent="user-agent: Whatever..." https://example.com/somewhere
IMAGE_URL=$(cat /tmp/output.html | pup --plain 'meta[property*="og:image"]' | sed -n 's/.*content=\"\([^"]*\)".*/\1/p')
于 2021-03-27T06:06:55.173 回答