
Python
文章平均质量分 68
zz198808
这个作者很懒,什么都没留下…
展开
-
python中如何判断一个变量的数据类型?(原创)
import types type(x) is types.IntType # 判断是否int 类型 type(x) is types.StringType #是否string类型 ......... -------------------------------------------------------- 超级恶心的模式,不用记住types.StringT原创 2013-06-08 13:24:24 · 1150 阅读 · 0 评论 -
自动下载百度音乐的脚本
#!/usr/bin/python #coding:utf8 #data:2013.07.03 #author: Finy import re,urllib #url='http://music.baidu.com' #url='http://music.baidu.com/top/new' url="http://music.baidu.com/top/dayhot" save_url_原创 2013-07-07 17:35:17 · 1130 阅读 · 0 评论 -
BeautifulSoup中文乱码解决问题 python 爬虫 乱码
importurllib2 2 fromBeautifulSoup importBeautifulSoup 3 4 page=urllib2.urlopen('http://www.leeon.me'); 5 soup原创 2013-07-07 13:36:35 · 2357 阅读 · 0 评论 -
Python学习笔记
Python介绍程序设计 基础语法变量运算符参数语句控制函数 数据结构 字符串列表字典元组 面向对象 基础对象属性对象方法运算符重载对象继承 高级编程 正则表达式文件处理XML 编程网络编程数据库常用标准库 参考资料 Python介绍 Python 是一种解释性语言,程序是被解释器来解析执行的。版本信息:$ python -Vpython 大小写敏感python 帮原创 2013-07-06 22:46:33 · 648 阅读 · 0 评论 -
用Python解析HTML,BeautifulSoup使用简介
装汤——Making the Soup 首先要把待解析的HTML装入BeautifulSoup。BeautifulSoup可以接受文件句柄或是字符串作为输入: from bs4 import BeautifulSoup fp = open("index.html") soup1 = BeautifulSoup(fp) soup2 = BeautifulSoup("data")原创 2013-07-07 00:33:12 · 5787 阅读 · 1 评论 -
Python中文全攻略 中文乱码 输出中文乱码
Python中文全攻略 作者:tamsyn 来源:www.sqlite.com.cn 时间:2007-4-25 【 字体:大 中 小 】 〖 双击滚屏 〗 插入数据库时,总是空,我做了如何操作,就好了。数据是采集过来的,程序是gbk编码person_sql="insert into analyst原创 2013-07-07 00:30:07 · 942 阅读 · 0 评论 -
糗百爬虫
from BeautifulSoup import BeautifulSoup import urllib2 import urllib outfile = open("qiubai1.txt", "w") def formalize(text): result = '' lines = text.split(u'\n') for line in lines:原创 2013-07-07 16:02:19 · 834 阅读 · 0 评论 -
python爬糗百
#coding=utf-8 #需要BeautifulSoup(美丽的汤)支持:http://crummy.com/software/BeautifulSoup import urllib import urllib2 from xml.sax.saxutils import unescape from BeautifulSoup import BeautifulSoup # F原创 2013-07-07 01:06:27 · 1079 阅读 · 0 评论 -
[Python]网络爬虫:Python中的正则表达式教程
接下来准备用糗百做一个爬虫的小例子。 但是在这之前,先详细的整理一下Python中的正则表达式的相关内容。 正则表达式在Python爬虫中的作用就像是老师点名时用的花名册一样,是必不可少的神兵利器。 一、 正则表达式基础 1.1.概念介绍 正则表达式是用于处理字符串的强大工具,它并不是Python的一部分。 其他编程语言中也有原创 2013-07-06 23:39:00 · 1025 阅读 · 1 评论 -
Windows 下 Python easy_install 的安装 并安装lxml扩展包
由于我的python版本是2.6所以安装setuptools-0.6c11.win32-py2.6 安装完后添加到环境变量中, 前提:已经装好了easy_install这个工具,不难装,网上一搜就有 1. 去lxml的官网http://lxml.de/installation.html 2. 什么都不用看,就看Installation下的ms windows, 然后打开wind原创 2013-07-06 23:18:59 · 1874 阅读 · 0 评论 -
Python爬虫
1.简单的获得页面内容 import urllib2 content = urllib2.urlopen('http://www.hao123.com').read() f=open("1.html",'w'); f.write(content) f.close() 但是这样存在一些站点采取了保护,因此要伪装成浏览器的正常请求, 2. # -*- coding: c原创 2013-07-06 22:40:32 · 756 阅读 · 0 评论 -
python获得天气
#! /usr/bin/python # -*- coding: cp936 -*- # coding = utf-8 # ToDo: get weather info from weather.com.cn # Author: Steven # Date: 2013/05/13 import urllib2 import json # get weather html and parse原创 2013-07-06 14:46:54 · 1093 阅读 · 0 评论