I'm a narcissist. (Not Really)

I'm also very lazy... (Not Really)

So I want to know the score of this question, and how many people have viewed it.

But I'm too lazy to check myself...


Your challenge is to output the score of this question, and how many views there are. No input may be taken, and output may be given as pretty much anything as long as it's clear where the two numbers are outputted. So, all of the following are valid:

[1, 1]
score 1, 1 view
1 1
1, 1

Note that pluralization matters, so "1 views" is invalid output.

I am very lazy, so I want this code to be as short as possible.
You may assume that there is an internet connection.
You may want to use the SE API. For reference, this question has id 111115.


No URL shorteners are allowed.
You may assume that votes are not expanded (for users below 1000 rep: users with at least 1000 rep can click on the score of a post to see the upvotes and downvotes individually. You may assume that this was not done).


This is a code-golf challenge, so the shortest valid submission by March 14th (Pi Day) wins! Happy golfing!

  • \$\begingroup\$ Related: Stack Exchange Vote Counter \$\endgroup\$
    – Dennis
    Commented Feb 24, 2017 at 2:18
  • \$\begingroup\$ @Dennis Hm. I did not find that in my search. Strange. Also, I have a question that you may be able to answer. Does the API tell you how many upvotes I have, or just the overall score? \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 2:20
  • \$\begingroup\$ Is usage of the SE API required? I don't see how it's "definitely" necessary (for example, one could scrape and parse the HTML of this page). \$\endgroup\$
    – Doorknob
    Commented Feb 24, 2017 at 2:20
  • \$\begingroup\$ @Doorknob That is true. Also, thanks for correcting my code; I forgot about being politically correct (I'm rather uncareful about that). \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 2:21
  • \$\begingroup\$ @HyperNeutrino I can't find the "views" attribute on the SE api, so I don't think it's even possible to solve this with the SE api. \$\endgroup\$ Commented Feb 24, 2017 at 2:21

7 Answers 7


T-SQL, 49 bytes

According to the FAQ the database will be updated on Sunday 0300 UTC so this is when you'll get your result. So I'm hoping you're a patient lazy (not really) narcissist (not really).

select Score,ViewCount
from Posts
where Id=111115


  • \$\begingroup\$ Haha. That's an interesting solution. :) I'm upvoting it, but I'm not considering it a valid solution for accepting, because it isn't always up to date (what if I get 10 upvotes between Sunday and Friday? I really want to see all those upvotes coming in... :P). But keep this here, good job! \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 14:09
  • \$\begingroup\$ @HyperNeutrino that's fair enough :) thanks \$\endgroup\$
    – ʰᵈˑ
    Commented Feb 24, 2017 at 14:22
  • 1
    \$\begingroup\$ chat.stackexchange.com/transcript/message/35817456#35817456 \$\endgroup\$
    – mbomb007
    Commented Mar 3, 2017 at 22:43

JavaScript + jQuery, 109 bytes

<!-- Click run | below! -->
<!--           v        --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Same strategy as my answer on a related question.

  • \$\begingroup\$ Yay, good job! +1 \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 2:41
  • \$\begingroup\$ @HyperNeutrino Editing to add comments. \$\endgroup\$ Commented Feb 24, 2017 at 2:41
  • \$\begingroup\$ Oh, okay. I just rolled that back because you submitted, but if you edit it, I'll unrollback. \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 2:45
  • \$\begingroup\$ @HyperNeutrino Actually, getting comments is a completely different request. I'm not going to add that. \$\endgroup\$ Commented Feb 24, 2017 at 2:46
  • \$\begingroup\$ Yeah. I think it actually requires /questions/comments/{ids}, so don't bother. I've rolled back already. \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 2:47

Javascript (ES6), 128 bytes

  • 1
    \$\begingroup\$ Huh, how long has fetch existed? I've never heard of it before... \$\endgroup\$ Commented Feb 24, 2017 at 12:44
  • \$\begingroup\$ @ETHproductions it's been in Chrome and Firefox since mid-2015 :D \$\endgroup\$
    – nderscore
    Commented Feb 24, 2017 at 16:31
  • \$\begingroup\$ Nice solution! +1 \$\endgroup\$
    – hyper-neutrino
    Commented Feb 26, 2017 at 20:17

JavaScript, 129 105 bytes

Non-API solution.


You should be able to run this in your browser's developer tools.

  • \$\begingroup\$ Yep, this works! Just one side note, when I expand out the votes (1000 rep feature), it no longer works, so I'll add into the specs that you may assume that the votes are not expanded. +1! :) \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 3:02
  • \$\begingroup\$ @HyperNeutrino It should now work for expanded votes. \$\endgroup\$
    – Oliver
    Commented Feb 24, 2017 at 15:08
  • \$\begingroup\$ Nice job! It's not necessary, but I see that you have shortened your solution as well. I've tested it and it now works as expected, giving me my upvote count, downvote count, and view count. \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 15:28

Bash + curl, 82 90 99 95 90 89 bytes

Edit 1: I had to do better searches to omit the keywords from my own answer, hence more bytes.

Edit 2: Using sed magic I got the byte count down again

curl -L codegolf.stackexchange.com/q/111115>f
grep -m1 t-post f
sed -n '/key.>\r/{n;p}' f

When curl accesses that short URL format, it receives a 302 redirection page that has this question's URL in the body section, so the -L option is needed to follow it. After that, it downloads the source code of this html page to a file named f. Then I search the keywords associated with the statistics wanted and print the answer on STDOUT.

Test: I redirect STDERR just for clarity (stats at the time of this posting)

me@LCARS:/PPCG$ ./Q_stats.sh 2> /dev/null
        <span itemprop="upvoteCount" class="vote-count-post ">7</span>
                                    <b>398 times</b>

The output is pretty verbose, but the syntax of both lines is basically junk text>VALUE<more junk text, which should be allowed according to the challenge description.

  • \$\begingroup\$ Yep, since the "junk text" is always consistent, this is a valid answer. Nice job! +1 \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 14:10
  • \$\begingroup\$ Removed my URL comment and explained it in the answer. \$\endgroup\$
    – seshoumara
    Commented Mar 3, 2017 at 20:52

Python 3 + requests, 150 143 bytes

(__import__("requests").get("http://api.stackexchange.com/questions/111115?site=codegolf").json()['items'][0][k]for k in('score','view_count'))

7 bytes shorter thanks to notjagan.

Output: [4, 270]

  • \$\begingroup\$ Good job! :) +1 \$\endgroup\$
    – hyper-neutrino
    Commented Mar 3, 2017 at 20:54
  • 1
    \$\begingroup\$ -7 bytes with [__import__("requests").get("http://api.stackexchange.com/questions/111115?site=codegolf").json()['items'][0][k]for k in('score','view_count')]. \$\endgroup\$
    – notjagan
    Commented Mar 3, 2017 at 22:05
  • \$\begingroup\$ @notjagan I edited it, but I'm not sure it's correct. Is an expression a valid output? \$\endgroup\$
    – L3viathan
    Commented Mar 3, 2017 at 22:40
  • 1
    \$\begingroup\$ A generator function as output is allowed. meta.codegolf.stackexchange.com/a/10753/34718 \$\endgroup\$
    – mbomb007
    Commented Mar 3, 2017 at 22:44
  • \$\begingroup\$ @mbomb007 Good point, editing it now. \$\endgroup\$
    – L3viathan
    Commented Mar 3, 2017 at 22:45

Powershell, 119 Bytes

,"-po.+?>(.+?)<","(\d+) times<"|%{[Regex]::Match((irm codegolf.stackexchange.com/questions/111115),$_).Groups[1].Value}

Outputs like

enter image description here

Shortest regex I could get to match exactly the vote count and nothing else, could make it shorter but then you would need to use Matches instead of Match

irm is short for Invoke-RestMethod and returns the raw page as text, then we just regex match the line

<span itemprop="upvoteCount" class="vote-count-post " title="View upvote and downvote totals" style="cursor: pointer;">4</span>

by looking for -po in count-post, up to the next >, then everything between that and the next < is captured and retrieved.

using basic request web parsing in powershell requires calls to things like getElementsByClassName which aren't very golf friendly, so the irm method seems to be shortest.

  • \$\begingroup\$ This isn't quite valid because it's missing the views. Additionally, could you add a link to an online Powershell emulator (I can't find one) or attach an animated image of you running your program? Thanks! \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 14:06
  • \$\begingroup\$ @HyperNeutrino Powershell is standard on any windows Machine, I've put an image in showing the results though. \$\endgroup\$
    – colsw
    Commented Feb 24, 2017 at 14:28
  • \$\begingroup\$ Yes, but I use Linux. :P \$\endgroup\$
    – hyper-neutrino
    Commented Feb 24, 2017 at 14:28
  • \$\begingroup\$ Alright, appears to work now! +1 \$\endgroup\$
    – hyper-neutrino
    Commented Feb 26, 2017 at 4:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.