dwm8
dwm8

Reputation: 307

MATLAB How to Use URLREAD with a Password Protected Website

I am trying to use urlread to grab the contents of a password protected website. When I'm logged in, the url is http://media.nba.com/Stats/OfficialBoxScores.aspx, and when logged out, the url is http://media.nba.com/Stats/Login.aspx?ReturnUrl=%2fStats%2fOfficialBoxScores.aspx. I've tried

urlread('http://media.nba.com/Stats/OfficialBoxScores.aspx','Username','username','Password','password');

with my login credentials but it only gives me the contents of the url before logging in. I see that this question has been asked before, but I couldn't find a solution for my situation. Is there a way to use urlread to get past the password protection wall?

Any help would be greatly appreciated!

Upvotes: 2

Views: 1592

Answers (2)

Blake
Blake

Reputation: 1

%Allows you to access url that requires username and password

url_login = 'https://www.your-website-loginpage'
url_data = 'https://www.your-website-data-url'
[stat,h] = web(url_login) %Enter username and password in the popup
setCurrentLocation(h, url_data)
pageText = h.getHtmlText()

Upvotes: 0

Hoki
Hoki

Reputation: 11802

You need to specify the method (use 'post'), and the parameters need to be a cell array of name/value pairs.

Does this work :

urlread('http://media.nba.com/Stats OfficialBoxScores.aspx','post',{'Username','username';'Password','password'} );

Upvotes: 0

Related Questions