0
votes

I am trying to scrape YouTube channel ID's (e.g. UCqwbZ-xTkn_EmyIhSvZRRWQ) and import it into Google Sheets using an IMPORTXML formula but getting no luck. The channel ID can be found in the page source of a channel (https://www.youtube.com/channel/UCqwbZ-xTkn_EmyIhSvZRRWQ)

Can anyone give some guidance please on how to go about this?

In the Google sheet, I have a list of YouTube channel URL's and wanted to scrape these ID's.

I have managed it with scraping the subscribers, just no luck with the channel ID's.

Any help will be appreciated.

2

2 Answers

0
votes
=ARRAYFORMULA(REGEXREPLACE(QUERY(SUBSTITUTE(ARRAY_CONSTRAIN(
 IMPORTDATA(A40), 3000, 1), """", ""),
 "where Col1 contains '<meta itemprop=channelId content='"),
 "<meta itemprop=channelId content=|>", ""))

0

0
votes

in your case, you don't need to scrape it from YouTube. try:

=REGEXEXTRACT(A2, "channel/(.+)")

0