The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: urlread2 get with headers
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 2
Registered: 1/18/12
urlread2 get with headers
Posted: Aug 19, 2014 8:15 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm trying to download some stats from a footy website, it requires me to connect to it to get the token then to use the token when requesting the data. I have it working in python but I'm trying to get it working in Matlab using urlread2 (
I'm also using jason lab to parse the json data when it returns

Yet im having some problems.

Getting the token works fine

addpath('C:\Users\Paul\Desktop\AFL Scraping\Matlab\jsonlab');
base_url = ''
token_url = [base_url 'WMCTok']
player_url = [base_url 'statsCentre/teams']
str = urlread(token_url,'post',{'0','0'})
token = json2data.token

But the next step I can't figure out.
The curel request from the site is
curl ""

and the token header is {'X-media-mis-token': token}

The python code that works in case anyone is interested is
import requests
import json
import csv
base_url = ''
token_url = base_url + 'WMCTok'
player_url = base_url + 'statsCentre/teams'
session = requests.Session() # session makes it simple to use the token across the requests
token =['token'] # get the token
session.headers.update({'X-media-mis-token': token}) # set the token
data = session.get(player_url + '?competitionId=CD_S2014014&roundId=CD_R201401401')
def printPretty(data):
print(json.dumps(data, sort_keys=True, indent=2, separators=(',', ': ')))


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.