Use MATLAB's webread to login to website and extract text

1.8k views Asked by At

I'm wondering how to extract text from a password protected website using Matlab's "webread" function. I have the following code (part of which i got from here):

values=inputdlg({'Url','Username:','Password'});
options=weboptions('Username',values{2},'Password',values{3},'Timeout',Inf);
html=webread(values{1},options);
txt = regexprep(html,'<script.*?/script>','');
txt = regexprep(txt,'<style.*?/style>','');
txt = regexprep(txt,'<.*?>','');

But it gets stuck at the login window for every webpage I've tried. Help? Ideas? Thanks.

2

There are 2 answers

0
Matt Krause On

The weboptions username and password parameters are for basic HTTP authentication, which is different than logging into Stack Exchange, Gmail, etc though the username and password boxes on a web page.

Some sites provide other mechanisms that might allow you to log in (like OAuth), and the File Exchange has a smattering of clients.

1
A. Fasih On

Here is an OAuth interface for login into the flicker using Matlab, maybe it help you. but you have to be sure that your website support this authentification method (as "Matt Krause" mentioned in his answer).

Link to Tutorial