0

I am trying to build a Youtube analysis template to monitor my channel's competition.

I would like to parse certain information from Socialblade, but I have just managed to get the information which has an name. The image below shows the xpath for Number of channel uploads:

Data has associated id

Channel's uploads

However, when I try to get information that doesn't have an associated to it I can't seem to be able to extract that information.

The data has no id

I have tried changing the xpath that Chrome generates automatically but had no success. Here's the original xpath for the Date of creation, which is the information I would like to import into Google Sheets:

enter image description here

When I insert this on Google Sheets I get an error message saying that there is a formula parse error.

How can I retrieve this information from SB's website and import it into Google Sheets?

djur
  • 304
  • 2
  • 13

2 Answers2

2

Just use the appropriate XPath :

=IMPORTXML(A1;"//span[.='User Created']/following-sibling::span")

SB

E.Wiest
  • 5,425
  • 2
  • 7
  • 12
  • Could you share the code to get the profile picture as well? I have used the following code but while it doesn't result in an erorr it doesn't retrieve the image from the src. =IMPORTXML(D2,"//img[@id='YouTubeUserTopInfoAvatar']") Any idea how to make it work? Thanks! – djur May 01 '20 at 08:33
  • For this you want the `src` attribute, in your xpath query, that's the image's url. Whith which you can import it into sheets. I've edited my answer to add this example. – Aerials May 01 '20 at 11:28
  • Use `=IMAGE(IMPORTXML(A1;"//img[@id='YouTubeUserTopInfoAvatar']/@src"))`. https://framapic.org/hyZm7QL3N2h3/JjOH08mAyB5K.PNG – E.Wiest May 01 '20 at 12:23
1

Perhaps this answer helps.

Also you appear to be concatenating wrong. Use single quotes like so:

=IMPORTXML(D2, "//span[.='User Created']/following-sibling::span")


If you want to get the url of an image, you can do so by fetching the "src" attribute of the image like:

=IMPORTXML("website-url", "//img[@id='image-tag-id']/@attribute-value-you-want")

Where you replace the parameters in the formula with real ones.


Then, if you would like to embed the image into the sheet, use:

=IMAGE(IMPORTXML("profile-url", "//img[@id='YouTubeUserTopInfoAvatar']/@src"))

and replace url with the user's profile url you want.

References:

Aerials
  • 4,231
  • 1
  • 16
  • 20
  • Unfortunately, this seems not to retrieve any results. I still got the same error. – djur Apr 30 '20 at 14:49
  • Can you share the error, is it parse error, or empty content from the response? – Aerials Apr 30 '20 at 14:53
  • It does seem to work now. I tried yesterday several times but it wouldn't work. Any ideas as to what code to use to retrieve the profile picture? I left a comment in the other response with the issue. Any help would be much appreciated. – djur May 01 '20 at 08:35