测试站点:百度新闻。抓取百度新闻热点新闻或者成都新闻区域内全部链接,将链接文字、链接url地址,回填到excel文件当中。
把下载到的新闻列表用pandas写进excel:
import pandas as pd
lst=[{'title':'新闻1','url':'http://....地址1'},{'title':'新闻2','url':'http://....地址2'},...,...]
news=pd.DataFrame(lst)
news.to_excel('baidunews.xlsx',index=False)