フィルターのクリア

webread examples don't work

22 ビュー (過去 30 日間)
YW
YW 2016 年 9 月 22 日
編集済み: per isakson 2017 年 8 月 16 日
I tried to find out how webread works. Following examples don't work for me.
>> filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
fullList = webread(filex);
Error using readContentFromWebService (line 45)
The server returned the message: "Server redirected too many times (20)" for URL,
'http://nroyaltonproxy:8889/?cfru=aHR0cDovL3d3dy5tYXRod29ya3MuY29tL21hdGxhYmNlbnRyYWwvZmlsZWV4Y2hhbmdlLw=='
(with HTTP response code unknown).
Error in webread (line 122)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
  1 件のコメント
lotus whit
lotus whit 2017 年 8 月 16 日
編集済み: per isakson 2017 年 8 月 16 日
I have the same problem when i called Google translation API, this is my code
url = 'https://translation.googleapis.com/language/translate/v2'
options.KeyName = 'apikey';
options.RequestMethod ='Get';
Options.ContentType ='Josn';
options.KeyValue='XXXXXX';
response = webread(url,options)
the following error appeared :
Error using readContentFromWebService (line 37)
The server returned the message: "Forbidden" for URL,
'https://translation.googleapis.com/language/translate/v2' (with
HTTP response code 403).
Error in webread (line 115)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
I filled key value as it is in my console, any one help?

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 9 月 22 日
You appear to be using a http proxy that is having difficulty with the site.
When I use telnet directly to the webserver port and make the request, I do not receive any redirect messages at all.
Oni:~ roberson$ telnet www.mathworks.com 80
Trying 23.4.13.144...
Connected to e6779.b.akamaiedge.net.
Escape character is '^]'.
GET http://www.mathworks.com/matlabcentral/fileexchange/ HTTP/1.0
HTTP/1.0 200 OK
Server: Apache/2.2.3 (CentOS)
X-UA-Compatible: IE=Edge,chrome=1
ETag: "6aac7270871d08f05076ae85c7d9b998"
X-Request-Id: d73f63c54278a9d1730b2e1f23605a5f
X-Runtime: 0.044456
X-Rack-Cache: miss
X-Powered-By: Phusion Passenger 4.0.59
Status: 200 OK
Content-Type: text/html; charset=utf-8
Expires: Thu, 22 Sep 2016 22:36:15 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 22 Sep 2016 22:36:15 GMT
Content-Length: 26612
Connection: close
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
(etc)
  6 件のコメント
Kirby Fears
Kirby Fears 2016 年 10 月 3 日
編集済み: Kirby Fears 2016 年 10 月 3 日
Since you're able to successfully visit that website in your browser, you can try manually changing the user agent so Matlab pretends to be a web browser. If this works, you can ask your IT support to allow for Matlab as a user agent.
opts = weboptions('UserAgent','Mozilla/5.0');
filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
fullList = webread(filex,opts);
Wyfi Mcfly
Wyfi Mcfly 2017 年 4 月 3 日
worked for my issue, thanks!

サインインしてコメントする。


YW
YW 2016 年 10 月 4 日
編集済み: Walter Roberson 2016 年 10 月 4 日
Still didn't work. See below:
>> opts = weboptions('UserAgent','Mozilla/5.0')
opts =
weboptions with properties:
CharacterEncoding: 'auto'
UserAgent: 'Mozilla/5.0'
Timeout: 5
Username: ''
Password: ''
KeyName: ''
KeyValue: ''
ContentType: 'auto'
ContentReader: []
MediaType: 'application/x-www-form-urlencoded'
RequestMethod: 'auto'
ArrayFormat: 'csv'
>> filex = 'http://www.mathworks.com/matlabcentral/fileexchange/'
filex =
http://www.mathworks.com/matlabcentral/fileexchange/
>> fullList = webread(filex,opts)
*Error using readContentFromWebService (line 45)
The server returned the message: "Server redirected too many times (20)" for
URL,
'http://nroyaltonproxy:8889/?cfru=aHR0cDovL3d3dy5tYXRod29ya3MuY29tL21hdGxhYmNlbnRyYWwvZmlsZWV4Y2hhbmdlLw=='
(with HTTP response code unknown).
Error in webread (line 122)
[varargout{1:nargout}] = readContentFromWebService(connection, options);*
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 10 月 4 日
You will probably need to contact your network people.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by