对网页的相关操作

对网页的相应操作

登录到163网站,保存下来首页

Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> url='http://www.163.com'
>>> content=urllib.urlopen(url).readline()  #保存下来第一行
>>> print content
 <!DOCTYPE html>

>>> filename=urllib.urlretrieve(url,filename="/mnt/newfile") #将网站内容保存在本地
[kiosk@desktop0 mnt]$ ls -l /mnt/newfile 
-rw-r--r-- 1 root root 750052 Apr  8 10:09 /mnt/newfile
posted @ 2016-07-25 16:07  夏日花开  阅读(83)  评论(0编辑  收藏  举报