(1)jupyter
Windows下打开命令行,输入pip3 install jupyter,等待安装完成以后,输入jupyter notebook即可在8888端口打开浏览器jupyter在线笔记本,里面的UrllibTest文件
(2)
更改jupyter-notebook启动时的默认目录
1.打开 cmd ,输入命令 jupyter notebook --generate-config,将生成 jupyter_notebook_config.py文件
2.在C:\Users\Administrator\.jupyter 中的文件找到文件 jupyter_notebook_config.py
3.用记事本打开找到 # The directory to use for notebooks and kernels.
修改这一句c.NotebookApp.notebook_dir = u'
为c.NotebookApp.notebook_dir = u'E:\\jupyternotebook'
注:将#号删除,路径是\\双斜线 ,E:\\jupyternotebook为自己想要设置的目录
(3)命令行爬取网页的图片
进入命令行,输入命令:python,进入python交互模式,输入命令:import requests,输入命令:response = requests.get('https://www.baidu.com/img/bd_logo1.png'),https://www.baidu.com/img/bd_logo1.png是网页上百度logo的URL链接,然后输入命令:with open('C:/Users/pc/Pictures/Saved Pictures/baidu.png',‘wb’)as f:
... f.write(response.content)
... f.close()
...
720
即可成功