I occasionally found the question of how to access the web page in matlab on the Internet and searched Baidu for a few answers. So I want to study what is going on. The implementation process is recorded as follows.
Before accessing a webpage, you must solve the problem. How does one prevent Chinese characters on the webpage from appearing on the display in garbled form? Foreigners are troublesome. They always need to solve similar problems caused by different languages. I am using the version of MATLAB A. In fact, all of them are similar. The specific situation is analyzed.
Therefore, we need to modify the urlread () function in matlab, because the urlread () function is used in matlab to parse the website content. We need to add a parameter in the urlread () function to solve the problem of garbled characters when accessing a Chinese website.
Then, use the regexp () regular function to extract the accessed website information.
The specific modification steps are as follows:
1. Enter the command line edit urlread in matlab to open the urlread. m file. We need to modify the file.
2. Understand the parameters of the file:
function [output,status] = urlread(urlChar,method,params);
Indicates that the file has three parameters. To implement the Chinese parsing function, add the webencoding parameter as follows:
function [output,status] = urlread(urlChar,method,params,webencoding);
Then add a syntax-compatible statement after the function as follows:
3. Because we have added or decreased a parameter, we need to modify the parameter quantity test Statement, which is about 41 rows.
Change 3 to error (nargchk (, nargin.
4. Modify the data conversion statement at the end of the file
'Utf-8'
5. Syntax call function Parsing
After the original file is modified and saved, write and call the function. The specific implementation is as follows: