上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 29 下一页
摘要: 爬取网页内容的时候,往往网页标签比较复杂,对于这种情况,需要用xpath的starts-with和string(.)功能属性来处理,具体看事例 #encoding=utf-8 from lxml import etree html1 = ''' <!DOCTYPE html> <html> <hea 阅读全文
posted @ 2016-03-06 10:52 北京流浪儿 阅读(793) 评论(0) 推荐(0) 编辑
摘要: 1、如果你没有安装lxml,请运行pip install lxml或者easy_install lxml安装,如果在安装过程中失败的话, 是因为lxml需要依赖某些库文件,具体可以问下度娘,这里不再赘述。 2、安装成功后,请看下面测试代码 //:定位根节点/:往下层寻找/text(): 提取文本内容 阅读全文
posted @ 2016-03-06 10:24 北京流浪儿 阅读(838) 评论(0) 推荐(0) 编辑
摘要: 1、使用file 函数直接读取 $starttime = microtime_float(); ini_set('memory_limit','-1'); $file = "testfile.txt"; $data = file($file); $line = count($data);//总行数 阅读全文
posted @ 2016-03-03 17:25 北京流浪儿 阅读(452) 评论(0) 推荐(0) 编辑
摘要: 1、工厂模式 <?php namespace Facebab; class Factory { static function createDatabase () { return new Database(); } } $db = Facebab\Factory::createDatabase() 阅读全文
posted @ 2016-03-03 10:50 北京流浪儿 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 1、自动装载实例 目录下有3个文件:index.php load.php tests文件夹 tests文件夹里有 test1.php <?php namespace Tests; class Test1{ static function test(){ echo __CLASS__.'<br>'; 阅读全文
posted @ 2016-03-03 10:32 北京流浪儿 阅读(194) 评论(0) 推荐(0) 编辑
摘要: #!/bin/sh #Today=`date +%Y%m%d` YEAR=`echo $1|cut -c 1-4` MONTH=`echo $1|cut -c 5-6` DAY=`echo $1|cut -c 7-8` TIME=$YEAR-$MONTH-$DAY #echo `date -d "$ 阅读全文
posted @ 2016-03-02 21:12 北京流浪儿 阅读(705) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8 class Tree(): def __init__(self,leftjd=0,rightjd=0,data=0): self.leftjd = leftjd self.rightjd = rightjd self.data = data class Btree() 阅读全文
posted @ 2016-03-02 15:34 北京流浪儿 阅读(818) 评论(0) 推荐(0) 编辑
摘要: 1、缓存配置 只需在http的server模块里配置即可,如: location ~.*\.(jpg|png|gif)$ { expires 30d; } location ~.*\.(css|js)?${ expires 1h; } 2、压缩配置 gzip on gzip_min_length 1 阅读全文
posted @ 2016-03-01 15:27 北京流浪儿 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 1、配置ip ifconfig eth0 192.168.1.7 netmask 255.255.255.0 ifconfig eth0 192.168.1.17 netmak 255.255.255.0 2、配置conf文件 /usr/local/nginx/conf/xnzj.conf user 阅读全文
posted @ 2016-02-29 17:10 北京流浪儿 阅读(416) 评论(0) 推荐(0) 编辑
摘要: 原创python爬虫代码 主要用到urllib2、BeautifulSoup模块 #encoding=utf-8 import re import requests import urllib2 import datetime import MySQLdb from bs4 import Beaut 阅读全文
posted @ 2016-02-29 11:47 北京流浪儿 阅读(1148) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 29 下一页