perloader

UnixBench跑分排行

测试方法: wget –no-check-certificate https://github.com/teddysun/across/raw/master/unixbench.sh chmod +x unixbench.sh ./unixbench.sh m247.ro,2核,1G内存,5 IP,KVM VPS,罗马尼亚,月付12.5€,2630.5 E5-2620v3 – 3.2Ghz next next next next

.

Read more

nginx 只允许特定IP访问

1.单独网站屏闭IP的方法: 在server”{}”,在这个大括号内加入deny IP地址是限制某IP地址访问;allow IP地址是只允许某IP地址访问; 如: allow 203.137.116.106; allow 118.0.0.0/8; deny all; 2.全局屏蔽 首先建立下面的配置文件放在nginx的conf目录下面,命名为blocksip.conf。比如我们要拒绝ip: deny 118.114.245.37; 保存一下。 在nginx的配置文件nginx.conf中加入:include blocksip.conf; 重启一下nginx的服务就可以生效了。

.

Read more

Nginx 反向代理以及正则替换内容

如果是为了隐藏源站IP而使用Nginx 反向代理,可以将源站域名替换为一个不存在的子域名,然后在代理机上vi /etc/hosts,将这个不存在的子域名指向源站IP。 安装nginx cd /root apt-get update apt-get install -y git gcc g++ make automake sudo apt-get install libpcre3 libpcre3-dev sudo apt-get install openssl libssl-dev apt-get install zlib1g-dev 或者 yum -y install pcre-devel openssl openssl-devel git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module wget http://nginx.org/download/nginx-1.2.8.tar.gz wget http://nginx.org/download/nginx-1.19.0.tar.gz tar zxvf nginx-1.2.8.tar.gz cd nginx-1.2.8 ./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module […]

.

Read more

win7安装MongoDB

下载mongodb-win32-x86_64-2.4.5.zip这个版本 解压至C盘,并建立C:\mongodb\DB文件夹和C:\mongodb\log\log.txt文件 管理员模式运行CMD cd mongodb\bin\ mongod.exe –logpath=C:\mongodb\log\log.txt –dbpath=C:\mongodb\data\db mongod.exe –install –logpath=C:\mongodb\log\log.txt –dbpath=C:\mongodb\data\db net start mongodb 启动mongodb服务 sc delete MongoDB 删除mongodb服务 启动后,再到命令行输入 mongo 如果成功的进入mongo的shell环境,那么就说明MongoDB已经安装成功了  

.

Read more

列表解析式

urls = [“http://www.hostloc.com/forum-45-{}.html”.format(str(i)) for i in range(1,15,1)] print(urls) 运行结果 [‘http://www.hostloc.com/forum-45-1.html’, ‘http://www.hostloc.com/forum-45-2.html’, ‘http://www.hostloc.com/forum-45-3.html’, ‘http://www.hostloc.com/forum-45-4.html’, ‘http://www.hostloc.com/forum-45-5.html’, ‘http://www.hostloc.com/forum-45-6.html’, ‘http://www.hostloc.com/forum-45-7.html’, ‘http://www.hostloc.com/forum-45-8.html’, ‘http://www.hostloc.com/forum-45-9.html’, ‘http://www.hostloc.com/forum-45-10.html’, ‘http://www.hostloc.com/forum-45-11.html’, ‘http://www.hostloc.com/forum-45-12.html’, ‘http://www.hostloc.com/forum-45-13.html’, ‘http://www.hostloc.com/forum-45-14.html’]

.

Read more

自写的第一个爬取图片实例

老套的爬图片实例,陆续写了几天,不容易,终于出来了。 难点有:分别为图片创建文件夹,爬取时不惧怕防盗链。 没有定义函数 比较难看,哈哈 from bs4 import BeautifulSoup import requests import urllib.request import os import re website = “http://www.sucaibar.com/image/meinv/” web_data = requests.get(website) soup = BeautifulSoup(web_data.text,’lxml’) urls= soup.select(‘#pic-list > li > a’) url_list = [] for url in urls: url_list.append(url.get(‘href’)) print(url_list) for url in url_list: web_data = requests.get(url) soup = BeautifulSoup(web_data.text,’lxml’) links= soup.select(‘body > div.content > […]

.

Read more

Windows上Python3.5安装lxml

pip install wheel http://www.lfd.uci.edu/~gohlke/pythonlibs/ 找到 lxml-3.6.4-cp35-cp35m-win32.whl lxml-3.6.4-cp35-cp35m-win_amd64.whl 放到Python 目录下 pip install lxml-3.6.4-cp35-cp35m-win_amd64.whl

.

Read more

火车头发布wordpress,定时发布过期,mysql批量修改

用火车头采集,然后发布至wordpress,由于时间成千上万条,定时发布会有很多失败也就是过期的,可以使用mysql命令行批量修改 。 先找出最近还没发布的post 的ID UPDATE wp_posts SET post_status = ‘publish’ WHERE ID < 23790 AND post_status = ‘future’;  

.

Read more

Python 片段

打印网页源代码 import urllib.request response = urllib.request.urlopen(“http://027886.xyz/”) print (response.read().decode(‘utf-8’)) 设置头部header head = {} head[‘User-Agent’] = ‘Mozilla ……’ head[‘Referer’] = ‘http://027886.xyz’ POST传送数据 import urllib.parse data = {} data[‘f’] = ‘undefined’ data[‘t’] = ‘undefined’ data[‘w’] = content 词霸翻译示例 import urllib.request import urllib.parse import json import time while True: content = input(‘请输入需要翻译的中文内容(输入“q!”退出程序):’) if content == ‘q!’: break url = […]

.

Read more

python 笔记

1.sum()函数接受一个list作为参数,并返回list所有元素之和。请计算 1*1 + 2*2 + 3*3 + … + 100*100。 L = [] x = 1 while x <= 100: L.append(x*x) x += 1 print (sum(L)) append() 方法用于在列表末尾添加新的对象。 以下实例展示了 append()函数的使用方法: #!/usr/bin/python aList = [123, ‘xyz’, ‘zara’, ‘abc’]; aList.append( 2009 ); print “Updated List : “, aList; 以上实例输出结果如下: Updated List : [123, ‘xyz’, ‘zara’, ‘abc’, 2009] […]

.

Read more
xyz