I want to get Twitter follower numbers on a google spreadsheet.
I used below line code and the result was N/A
=importXML("https://twitter.com/elonmusk","//a[@href='/elonmusk/followers']/span[@class='css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0'")
The HTML code is
<a href="/elonmusk/followers" dir="auto" role="link" class="css-4rbku5 css-18t94o4 css-901oao r-18jsvk2 r-1loqt21 r-1qd0xha r-a023e6 r-16dba41 r-rjixqe r-bcqeeo r-qvutc0">
<span class="css-901oao css-16my406 r-18jsvk2 r-poiln3 r-b88u0q r-bcqeeo r-qvutc0">
<span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">54.8M</span></span>
<span class="css-901oao css-16my406 r-m0bqgq r-poiln3 r-bcqeeo r-qvutc0">
<span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Followers</span></span></a>
Please take a closer look at the span nodes. The span you are trying to target is actually nested within the prior span, it is not a sibling. Try changing this:
to something like the following (note /span/span instead of /span to reflect the actual hierarchy (a/span/span):
or the following (note //span instead of /span) if you don't care about the hierarchy between the a and target span nodes: