[Question]
  [
We see a lot of challenges here asking for a function to create a sequence from the [OEIS](https://oeis.org/). 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](https://oeis.org/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](https://oeis.org/wiki/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.
  
[Answer]
# Bash + coreutils + w3m, ~~51~~ ~~45~~ 42 bytes
```
w3m oeis.org/b${1:1}.txt|sed "s/^$2 //p;d"
```
*Thanks to @EamonOlive for golfing off 3 bytes!*
### Example run
```
$ bash oeis.sh A172141 7
980
```
### How it works
[*w3m*](http://w3m.sourceforge.net/) is a text-based web browser, which displays both HTML and plain text in readable format. Unlike *curl*, it follows redirects by default (this is required, since `oeis.org/bxxxxxx.txt` redirects to `oeis.org/Axxxxxx/bxxxxxx.txt`), doesn't produce any stray output to STDERR, and has a three-byte name.
The command
```
w3m oeis.org/b${1:1}.txt
```
the desired URL, where `${1:1}` is the first command-line argument without its first character.
The output is piped to the command
```
sed "s/^$2 //p;d"
```
which extracts the desired output. `s/^$2 //p` attempts to replace `^$2` (start of line, followed by the second command-line argument, followed by a space) with the empty string. If the substitution is successful, `p` prints its result. Afterwards, `d` unconditionally deletes the pattern to prevent *sed* from printing the entire input.
[Answer]
# Mathematica + [OEIS.m](http://oeis.org/wiki/User%3aEnrique_P%C3%A9rez_Herrero/OEIS_Package#Download_and_Install_OEIS.m), 31
```
(OEISFunction@ToString@#;#@#2)&
```
example usage: `%[A172141,36]`
---
# Mathematica, 85
```
#2/.Rule@@@Import["http://oeis.org/b"<>#~StringDrop~1<>".txt","Data"]~DeleteCases~{}&
```
example usage: `%["A002206",-1]`
[Answer]
## Perl, 59 bytes
```
($_,$v)=@ARGV;/./;say`curl oeis.org/$_/b$'.txt`=~/$v (.*)/m
```
Needs `-M5.010` or `-E` to run. For instance : 
```
$ cat oeis.pl
($_,$v)=@ARGV;/./;say`curl oeis.org/$_/b$'.txt`=~/$v (.*)/m
$ perl -M5.010 oeis.pl A178932 5 2>&-
27
```
*Saved 8 bytes thanks to @Dennis [answer](https://codegolf.stackexchange.com/a/89386/55508), by removing `http://`, as he did.* 
[Answer]
# CJam, 36 bytes
```
"oeis.org/b"r1>+".txt"+gN%Sf%z~\ra#=
```
### Example run
```
$ cjam oeis.cjam <<< 'A172141 7'
980
```
[Answer]
# Python 2, ~~125~~ ~~118~~ 113 bytes
***~~7~~ 12 bytes saved thanks to Lynn***
```
import re,urllib2 as u;lambda x,y:re.findall("(?<=%d ).*"%y,u.urlopen("http://oeis.org/b%s.txt"%x[1:]).read())[0]
```
Well heres my go at my own problem. It is likely suboptimal but I think I did a pretty decent job. It creates an anonymous function that takes a string and integer as arguments and returns a string as the result or throws an error if the index is out of range.
This can be made into a 124 bytes full program.
```
import re,urllib2 as u;print re.findall("(?<=%d ).*"%input(),u.urlopen("http://oeis.org/b%s.txt"%raw_input()[1:]).read())[0]
```
This prompts the user for the input. First asking for the index and then the A-number of the sequence.
[Answer]
# Python 3, ~~153~~ ~~146~~ 135 bytes
**7 bytes thanks to FryAmTheEggman.**
**6 bytes thanks to Eamon Olive.**
**5 bytes thanks to Rod.**
```
from urllib.request import*
def f(a,n):
 for l in urlopen("http://oeis.org/b%s.txt"%a[1:]):
  p,q=l.split()
  if n==p.decode():return q
```
Call it like this:
```
print(f("A000796","314"))
```
Run on a machine where the default is utf-8.
[Answer]
# PHP 5.6, ~~93~~ 92 bytes
```
function f($i,$l){echo explode(' ',file('http://oeis.org/b'.substr($i,1).'.txt')[--$l])[1];}
```
This one is pretty straight forward. Pull the page with `file()`, get the line at `$line - 1` (0-index), explode on the space and print out the second array element from that.
[Answer]
# [Nim](http://nim-lang.org/), ~~123~~ ~~115~~ 113 bytes
```
import httpclient,nre,future
(a,n)=>get getContent("http://oeis.org/b"&a[1..^0]&".txt").find re "(?<="&n&r" )\d+"
```
This is a lambda expression; to use it, it must be passed as an argument to a testing procedure. A complete program that can be used for testing is given here:
```
import httpclient,nre,future
proc test(x: (string, string) -> RegexMatch) = echo x("A172141", "7") # Your input here
test((a,n)=>get getContent("http://oeis.org/b"&a[1..^0]&".txt").find re "(?<="&n&r" )\d+")
```
Expects input as two strings. Example usage:
```
$ nim c oeis.nim
$ ./oeis
980
```
We use `httpclient`'s `getContent` proc to get the OEIS b-file, then use a regex to `find` the line with the index. `find` returns an `Option[RegexMatch]`, so we use `get` to retrieve the value from the `Option`. `echo` automatically stringifies, so we leave stringification out.
[Answer]
## R, ~~94~~ 89 bytes
```
t=read.table(paste0("http://oeis.org/b",substring(scan(,""),2),".txt"));t[t$V1==scan(),2]
```
Using `sprintf` instead of `paste0` results in the same bytecount:
```
t=read.table(sprintf("http://oeis.org/b%s.txt",substring(scan(,""),2)));t[t$V1==scan(),2]
```
*Five bytes saved thanks to [plannapus](https://codegolf.stackexchange.com/users/6741/plannapus).*
[Answer]
## Clojure, 103
```
#(read-string((re-find(re-pattern(str %2" (\\d+)"))(slurp(str"http://oeis.org/b"(subs % 1)".txt")))1)))
```
`re-find` finds a vector of first matche's regex groups, it is used as a function and `1` gets the string at position `1`. `read-string` converts string to int. I'm not 100% sure if this regex always finds the correct row.
[Answer]
# R, 87 bytes
```
f=function(A,n)(R<-read.table(gsub("A(\\d+)","http://oeis.org/b\\1.txt",A)))[R$V1==n,2]
```
Build the URL string with regexes instead of `paste` or `sprintf`.
[Answer]
# Node.js + `request`, 109 bytes
```
x=>n=>require('request')(`http://oeis.org/b${x.slice(1)}.txt`,(a,b)=>console.log(b.body.match(n+` (.+)`)[1]))
```
Takes the sequence ID and a number.
[Answer]
# Julia, 88 bytes
```
x\y=match(Regex("$y (.*)"),readall(Requests.get("http://oeis.org/b$(x[2:end]).txt")))[1]
```
*Golfed with some help from @Dennis!*
Make sure you have `Requests.jl` installed before running.
[Answer]
## [ListSharp](https://github.com/timopomer/ListSharp), 266 bytes
```
STRG a=READ[<here>+"\\a.txt"]
ROWS x=ROWSPLIT a BY [","]
STRG a=GETRANGE x[0] FROM [2] TO [a LENGTH]
NUMB y=<c#int.Parse(x[1])c#>
STRG a=DOWNLOAD["http://oeis.org/b"+a+".txt"]
ROWS x=ROWSPLIT a BY [<newline>]
STRG a=GETLINE x [y]
ROWS x=ROWSPLIT a BY [" "]
SHOW=x[1]
```
Its sad when a language made for web scraping needs so many lines because nesting statements in ListSharp is *taboo*
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 29 bytes
```
¦’ÏÁ€ˆ.µÔ/bÿ.í¼t’.w¶¡€#˜DIk>è
```
Beats all other answers.
```
¦’...’.w¶¡€#˜DIk>è  # trimmed program
                 è  # 0-based...
               k    # 0-based index of...
              I     # input...
               k    # in...
            ˜D      # flattened list of...
      .w            # content of response from url...
                    # (implicit) "http://" concatenated with...
 ’...’              # "oeis.org/bÿ.txt"...
                    # (implicit) with ÿ replaced by...
                    # implicit input...
¦                   # excluding the first character...
         ¡          # split by...
        ¶           # newlines...
          €         # with each element...
           #        # split by spaces...
                >   # plus 1...
                 è  # th element in...
            ˜       # flattened list of...
      .w            # content of response from url...
                    # (implicit) "http://" concatenated with...
 ’...’              # "oeis.org/bÿ.txt"...
                    # (implicit) with ÿ replaced by...
                    # implicit input...
¦                   # excluding the first character...
         ¡          # split by...
        ¶           # newlines...
          €         # with each element...
           #        # split by spaces
```
]