Implement the webpage access function in MATLAB -- urlread () function

Source: Internet
Author: User

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:

 








Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.