Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python技术分享[5]- splinter自动登录微博和qq空间 #46

Open
lovecn opened this issue Nov 20, 2016 · 0 comments
Open

python技术分享[5]- splinter自动登录微博和qq空间 #46

lovecn opened this issue Nov 20, 2016 · 0 comments

Comments

@lovecn
Copy link
Owner

lovecn commented Nov 20, 2016

#!/usr/bin/python
# coding=utf-8
"""
利用splinter模块模拟发布微博,仅为QA讲例测试http://www.djhull.com/python/training-python-5.html 
"""
from splinter.browser import Browser
import random
import time

web_firefox = Browser('firefox')
web_firefox.visit('http://weibo.com/login.php')

if web_firefox.find_by_name('username'):
    print 'uname'
    # web_firefox.find_by_name('username').click()
    # 这个地方用by_name能找到,但是模拟点击时有问题,改成by_css
    web_firefox.find_by_css(
        "input[node-type=\"username\"]").fill('[email protected]')
time.sleep(random.randint(3, 10))

if web_firefox.find_by_name('password'):
    print 'passwd'
    web_firefox.find_by_css("input[node-type=\"password\"]").fill('******')

time.sleep(random.randint(3, 15))
print web_firefox.find_by_css(".loginbox .W_login_form .login_btn div a ")[0].click()

time.sleep(random.randint(3, 10))
print web_firefox.find_by_css(".input .W_input").fill(u'我说不让你用微博测试,你非用,得了吧。。。。 封ip了吧')

time.sleep(random.randint(3, 10))
print web_firefox.find_by_css("a[node-type=\"submit\"]").click()

>>> (1400.20-1400)*100
=> 20.000000000005
>>> bcmul((1400.26-1400),100)
=> "25"
>>> 1400.26-1400
=> 0.25999999999999
>>> bcsub(1400.26,1400,2)
=> "0.26"
微信自定义分享内容以及微信 token 的持续获取,基于 php+redis  github https://github.com/biggercool/WeChatToken 
https://yiqixie.com/s/home/fcABYO1x7nPoTUG3Wyw5Oj42Y    一个公开的可读写的表格工具,任何人都可以分享你知道的公司信息 把安卓上的一个 url 发到台式机浏览器的 隐私的走 https://cl1p.net  githubhttps://github.com/plantain-00/copy-tool  https://suoba.ml/  https://m4rk.org/ 
微信小程序版的 V2 客户端githubhttps://github.com/bestony/weapp-V2ex     https://github.com/wuxc/gitjump/blob/master/gitjump.sh github源文件域名raw.githubusercontent.com,文件为 https://raw.githubusercontent.com/wuxc/gitjump/master/gitjump.sh  一步步跟踪 git 的 commit 历史来学习源码

githubhttps://github.com/plantain-00/copy-tool  https://suoba.ml/  https://m4rk.org/ 

MySQL中英文混合排序最简单的办法http://www.nowamagic.net/academy/detail/32161508
select tag, COUNT(tag) from news GROUP BY tag order by convert(tag using gbk) collate gbk_chinese_ci;
《忽悠的原理与技巧》目录、腰封与阅读提示https://zhuanlan.zhihu.com/p/19977877

python lxml包学习笔记http://cangfengzhe.github.io/python/python-lxml.html 

javascript中使用php变量,需用引号引起,作为字符串使用var url = 'data.php?table='+ "<?php echo $_GET['type']; ?>" + '&q=' + "<?php echo $_GET['name']; ?>";
http://cangfengzhe.github.io/mysql/mysql%E5%AD%A6%E4%B9%A0.html
if (!preg_match('#^1[345|789]\d{9}$#',$user_phone)) {
            return Response()->jsonError(10006, '手机格式不对');
        }mysql> select * into outfile "manager.txt" fields terminated by ',' lines termin
ated by '\r\n' from manager;

Python爬虫开发(二):整站爬虫与Web挖掘http://www.freebuf.com/news/topnews/96821.html 
http://cangfengzhe.github.io/python/learn-python.html
箭头函数是 ES6 中的新特性,函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象。
var x = 0;
function test(){
    console.log(this.x);
}
var o={};
o.x = 1;
o.m = test;
o.m.apply(); //这里输出结果为:0。
o.m.apply(o); //这里输出结果为:1。
// apply()的参数为空时,默认调用全局对象。因此,第一次的运行结果为0,证明this指的是全局对象。
// apply(o), this 指向 o, this.x 指向 o.x,所以输出结果为 1. http://tingandpeng.com/2016/07/19/JavaScript-this%E5%85%B3%E9%94%AE%E5%AD%97/
[...document.querySelectorAll('div')] console.log(1, ...[2, 3, 4], 5)
// 1 2 3 4 5
var numbers = [4, 38];
add(...numbers) // 42
// arguments 变量的写法
function sortNumbers() {
  return Array.prototype.slice.call(arguments).sort();
}
// rest 参数的写法
const sortNumbers = (...numbers) => numbers.sort();#在字典中插入一个值
    sample_dict.update({3:'c','2':'b'}) http://www.djhull.com/python/training-python-3.html

function array_sum_with_key(array $arr1, array $arr2, array $_ = null)
{
    $args = array_slice(func_get_args(), 1);

    foreach ($args as $arr) {
        foreach ($arr as $k => $v) {
            if (isset($arr1[$k])) {
                $arr1[$k] += $v;
            } else {
                $arr1[$k] = $v;
            }
        }
    }

    return $arr1;
}

$regCount = Cache::increment("webinar:{$webinarId}:reg_count");
            if ($regCount == '1') {
                $regCount = self::syncCount($webinarId);
$model = new self();第一次同步数据 强制走主数据库 
        $count = $model->setConnection('master_write')->where('webinar_id', $webinarId)->count();
            }

###################################################
#  
#  功能:统计游戏中玩家及玩家登陆次数http://www.djhull.com/python/training-python-3.html
#        
####################################################

#统计游戏中玩家及玩家登陆次数
games = ['a','b','a','c','d','a','b','c','b']  
from collections import Counter  
d = Counter(games) 
print d


#排位赛规则,如果积分相同,则按胜利场次,再相同按失败场次
games =[{'f':3,'s':10,'b':12},{'f':3,'s':10,'b':12},{'f':13,'s':20,'b':16},{'f':13,'s':12,'b':12},{'f':13,'s':10,'b':12},]
from operator import itemgetter  
print sorted(games ,key = itemgetter('f','s','b'),reverse=True)


#选择某一天,然后以这天为准,次日留存,3日留存,7日留存,14日留存,30日留存
from datetime import datetime,timedelta  
def GetNextDay(baseday,n):  
    return str((datetime.strptime(str(baseday),'%Y-%m-%d')+timedelta(days=n)).date())  

import functools  
selected_day = '2015-02-01'
nday = functools.partial(GetNextDay,selected_day)
print nday(1)
print nday(2)
print nday(6)
print nday(13)
print nday(29)

#用来计算游戏包裹里面的变化情况
def symmetric_difference(_oldobj,_newobj):  
    _oldkeys = _oldobj.keys()  
    _newkeys = _newobj.keys()  
    _diff = {}  
    for _key in set(_oldkeys + _newkeys):  
        _val = _newobj.get(_key,0) - _oldobj.get(_key,0)  
        if _val:  
            _diff[_key] = _val   
    return _diff   

oldobj = {'a':1,'b':2,'c':3}  
newobj = {'a':1,'b':3,'d':4}  
print symmetric_difference(oldobj,newobj) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant