<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>takuya_1st</author_name>
  <author_url>https://blog.hatena.ne.jp/takuya_1st/</author_url>
  <blog_title>それマグで！</blog_title>
  <blog_url>https://takuya-1st.hatenablog.jp/</blog_url>
  <categories>
    <anon>grep</anon>
    <anon>curl</anon>
    <anon>スクレイピング</anon>
  </categories>
  <description>grep で HTMLタグの値を取り出す。 curl と組み合わせて戦う curl $URL | grep -oP '(?&lt;=name=&quot;post_id&quot; type=&quot;hidden&quot; value=&quot;).+(?=&quot; /&gt;)' grep では後方参照がいい感じに取れないので、「後読み（lookbehind）や先読み（lookahead）」を使って対応することになる。 HTMLのinputのvalueを取り出す例 次のようなHTMLがあって、valueだけを取り出したい。とする、。 &lt;input name=&quot;post_id&quot; type=&quot;hidden&quot; value=&quot;XxICIHRNcDFBr9Rl…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftakuya-1st.hatenablog.jp%2Fentry%2F2023%2F05%2F23%2F170351&quot; title=&quot; curlとgrep でHTMLから指定IDを取り出す。/ 後方参照の代替 - それマグで！&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2023-05-23 17:03:51</published>
  <title> curlとgrep でHTMLから指定IDを取り出す。/ 後方参照の代替</title>
  <type>rich</type>
  <url>https://takuya-1st.hatenablog.jp/entry/2023/05/23/170351</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
