matlab访问人民日报

xiaoxiao2021-02-28  36

function Renmingribaocontent()     clc     % clear     formatOut1 = 'yyyy-mm/dd';     todaydate1=datestr(now,formatOut1);     %http://paper.people.com.cn/rmrb/html/2018-02/17/nw.D110000renmrb_20180217_1-01.htm     formatOut2 = 'yyyymmdd';     todaydate2=datestr(now,formatOut2);     for id=1:10         try         renmingribao=strcat('http://paper.people.com.cn/rmrb/html/',num2str(todaydate1),'/nw.D110000renmrb_',...                            num2str(todaydate2),'_',num2str(id),'-01.htm')';         substr=content(id,renmingribao)         end     end end function [substr]=content(id,renmingribao)     urlcontent=urlread(renmingribao);     expression = '<(title).*>.*</\1>';     [tokens,matches] = regexp(urlcontent,expression,'tokens','match');     substr=char(matches);     row =strfind(substr,'>');     substr=substr(row(1)+1:end);     row =strfind(substr,'<');     substr=substr(1:row(1)-1); end
转载请注明原文地址: https://www.6miu.com/read-2626380.html

最新回复(0)