Skip to content

Instantly share code, notes, and snippets.

@nabakdev
Created November 29, 2022 10:42
Show Gist options
  • Select an option

  • Save nabakdev/bfee71349fab653e67be41e5da5c102c to your computer and use it in GitHub Desktop.

Select an option

Save nabakdev/bfee71349fab653e67be41e5da5c102c to your computer and use it in GitHub Desktop.
Get youtube view count [BASH][CURL]
#!/bin/bash
curl "https://m.youtube.com/watch?v=${VID_ID}" \
-s \
-H 'authority: m.youtube.com' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'cache-control: max-age=0' \
-H 'dnt: 1' \
-H 'sec-fetch-dest: document' \
-H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-site: same-site' \
-H 'sec-fetch-user: ?1' \
-H 'sec-gpc: 1' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1' \
--compressed | sed -n 's/^.*viewCount":"\([[:digit:]]\+\)".*$/\1/p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment