MATLAB urlread will not work for a specific web page

I am trying to clear a webpage using a function urlread()in MATLAB, although I ran into a problem that I had not seen before. When i run the code

X = urlread('http://espn.go.com/mens-college-basketball/schedule/_/date/20141114');

I get an error

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{:});

When I try to visit the link in my browser ( http://espn.go.com/mens-college-basketball/schedule/_/date/20141114 ), I have no problems accessing the page. Can anyone solve this problem?

+4
source share
3 answers

It looks like the site is blocking the default user-agent parameter MATLAB Rxxxxxin the http request.

Faking a user agent seems to limit the limitation:

x = urlread('http://espn.go.com/mens-college-basketball/schedule/_/date/20141114', 'UserAgent', 'Mozilla/5.0');
+5

, .

URL = 'http://espn.go.com/mens-college-basketball/schedule/_/date/20141114';
str = urlread(URL,'Get',{'term','urlread'});
0

, r Python -.

R script, .

library(rvest)
rawhtml <- read_html("http://espn.go.com/mens-college-basketball/schedule/_/date/20141114")
rvested <- rawhtml %>% 
    html_nodes("table") %>%
    html_table(fill = TRUE) %>%
    .[[1]]
0

Source: https://habr.com/ru/post/1615657/


All Articles