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?

2 Answers 2

2

Just use the appropriate XPath :

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

SB

Sign up to request clarification or add additional context in comments.

3 Comments

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!
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.
Use =IMAGE(IMPORTXML(A1;"//img[@id='YouTubeUserTopInfoAvatar']/@src")). framapic.org/hyZm7QL3N2h3/JjOH08mAyB5K.PNG
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:

3 Comments

Unfortunately, this seems not to retrieve any results. I still got the same error.
Can you share the error, is it parse error, or empty content from the response?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.