We see a lot of challenges here asking for a function to create a sequence from the OEIS. While these challenges are fun, as a programmer I see an opportunity for automation.
Your challenge is to make a program that takes the index of a sequence (e.g. A172141) and some integer n (e.g. 7), and pulls the appropriate value from the appropriate webpage.
I/O
As mentioned, your program should take a sequence index and some value n as input and output the nth term in that sequence. You accept any index in the sequence's B-files. If the index is greater than the largest index listed in the B-files you may throw an exception or output whatever you choose (these are not in the test cases). Standard methods of input and output are permitted.
Restrictions on web use
You should not access any websites other than https://oeis.org and http://oeis.org. This includes url shorteners, your own personal website, and this question itself. If you would like to access some other website and you believe that it is not unfair to allow you to do so, you can leave a comment and I will arbitrate.
Scoring
This is a code golf challenge so the program with the least bytes used in its source code wins. Standard loopholes are disallowed.
Test Cases
Assuming that your machine has proper internet connection and the OEIS servers are up and running the following inputs and outputs should correspond.
A172141, 7 -> 980
A173429, 4 -> 276
A190394, 6 -> 16
A002911, 11 -> 960
A052170, 3 -> 24
A060296, 8 -> 3
A178732, 5 -> 27
A000001, 1 -> 1
A000796, 314 -> 3
A001622, 162 -> 8
A002206, -1 -> 1
Tip
- When accessing the B-files
http://oeis.org/b<A-number>.txt
will redirect to the proper B-file.
oeis.org/A000796/b000796.txt
rather thanoeis.org/A000796/list
. Is the fomer what you mean by B-files? In that case, mentioning the offset is rather superfluous. \$\endgroup\$