页面url的可连接性,页面url连接性,import reimp
文章由Byrx.net分享于2019-03-23 08:03:10
页面url的可连接性,页面url连接性,import reimp
import reimport urllibimport urllib2from bs4 import BeautifulSoupprint 'nihao'url = "http://zhiqq.com"s = urllib2.urlopen('http://zhiqq.com')s = s.read()htm = unicode(s,'gb2312','ignore').encode('utf-8','ignore')soup = BeautifulSoup(htm)sou = soup.prettify()f = open('C:/sou.txt','w')f.write(sou)n = 0for link in soup.find_all('a'): print link.get('href') print n n = n+1 try: urllib2.urlopen(link.get('href')).getcode() except: print "*******connect failed" continue#该片段来自于http://byrx.net
相关内容
- Python 冒泡排序,python冒泡排序,num = [23,2,
- Python hashlib模块,pythonhashlib模块,hashlib是个专门提
- Python 动态规划算法,计算单词距离,python算法,#!/usr/bi
- scrapy 在不同的抓取级别的Request之间传递参数的办法,
- python通过xlrd模块读写Excel文件,pythonxlrd,一、安装xlrd模
- python标准算法实现数组全排列代码,python标准算法数组
- 查看所输入年月的日历,查看年月日历,#coding:utf-
- python通过luhn算法实现的信用卡卡号验证代码,pythonlu
- Python 把金额小写转换成大写,python小写,def IIf( b,
- 使用 ensureBuffer 快速填充数组,ensurebuffer数组,import ch
评论关闭