问题描述
我试图使用MATLAB中的urlread()
函数抓取网页,尽管我遇到了一个以前从未见过的问题.当我运行代码
I am attempting to scrape a webpage using the urlread()
function in MATLAB, though I've run into a problem that I haven't seen before. When I run the code
X = urlread('http://espn.go.com/mens-college-basketball/schedule/_/date/20141114');
我得到了错误
Error using urlreadwrite (line 92)The server did not find a resource to match this request.
Error using urlreadwrite (line 92)The server did not find a resource to match this request.
Error in urlread (line 36)[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
Error in urlread (line 36)[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
当我尝试访问浏览器上的链接时( http://espn.go.com/mens-college-basketball/schedule/_/date/20141114 ),访问该页面没有问题.有人能解决这个问题吗?
When I attempt to visit the link on my browser (http://espn.go.com/mens-college-basketball/schedule/_/date/20141114), I have no problems accessing the page. Does anyone have a solution to this problem?
推荐答案
该网站似乎正在阻止http请求中的默认MATLAB Rxxxxx
用户代理参数.
It appears that the site is blocking the default MATLAB Rxxxxx
user-agent parameter in the http request.
限制用户代理似乎可以解决此限制:
Faking the user-agent seems to work around the limitation:
x = urlread('http://espn.go.com/mens-college-basketball/schedule/_/date/20141114', 'UserAgent', 'Mozilla/5.0');
这篇关于MATLAB urlread无法用于特定网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!