百度移动排名点击器_v3.0

【GOGO闯】百度移动排名点击器_v3.0!巧用数据类型、python+selenium实现。
已实现功能:
1、每次点击通过adsl拨号或代理切换ip;且用过的代理ip进行标记,确保不会再次使用
2、先提前查询目标网站排名,然后随机点击,最后一次点击目标网站
3、对IOS、Android在百度移动搜索html的差异性进行兼容,确保元素能够准确定位
4、收集移动UA库,随机轮换大量UA,达到百度移动正常的Android:IOS访问比例
5、退出浏览器前先清空cookie,防止百度通过游客识别码进行识别
6、可设置点击关键词、目标网站和要点击的次数

重点是:然并软

#coding:utf-8
 
'''导入selenium中的webdriver包,只有导入这个包才能使用webdriver api 进行自动化脚本开发'''
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.proxy import *
import time,re,random
 
myProxy_list = []
 
def getUA():
    uaList = [
        #ios user agent
        'Mozilla/5.0 (iPhone 5CGLOBAL; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/6.0 MQQBrowser/5.8 Mobile/12F70 Safari/8536.25',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4',
        'Mozilla/5.0 (iPhone 5CGLOBAL; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/6.0 MQQBrowser/5.7 Mobile/12B466 Safari/8536.25',
        'Mozilla/5.0 (iPhone 5CGLOBAL; CPU iPhone OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/6.0 MQQBrowser/5.6 Mobile/12B440 Safari/8536.25',
        'Mozilla/5.0 (iPhone 5CGLOBAL; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/6.0 MQQBrowser/5.5 Mobile/12B435 Safari/8536.25',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/12B411 UCBrowser/10.0.5.508 Mobile',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/12A405 UCBrowser/10.0.2.497 Mobile',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/12B411 UCBrowser/10.1.0.518 Mobile WindVane tae_sdk_ios_1.0.1',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B411 MicroMessenger/6.0 NetType/WIFI',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/12B411 UCBrowser/10.0.5.508 Mobile',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A405 Safari/600.1.4',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_6 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B651 Safari/9537.53',
        'Mozilla/5.0 (iPhone 5CGLOBAL; CPU iPhone OS 7_0_6 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/6.0 MQQBrowser/5.0.5 Mobile/11B651 Safari/8536.25',
        'Mozilla/5.0 (iPhone 5CGLOBAL; CPU iPhone OS 7_0_5 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/6.0 MQQBrowser/5.0.4 Mobile/11B601 Safari/8536.25',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/31.0.1650.18 Mobile/11B554a Safari/8536.25',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a UCBrowser/9.3.1.339 Mobile',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a Safari/7534.48.3',
        'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53',
 
        #android user agent
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; MI 4LTE Build/KTU84P) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baiduboxapp/6.5.1 (Baidu; P1 4.4.4)",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; MI 4LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 XiaoMi/MiuiBrowser/2.1.1",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; MI 4LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.8 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTE Build/KTU84P) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baiduboxapp/6.5 (Baidu; P1 4.4.4)",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.8 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; SCH-N719 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.4.2; zh-cn; X9180 Build/KVT49L) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.4 TBS/025411 Mobile Safari/533.1 MicroMessenger/6.1.0.66_r1062275.542 NetType/WIFI",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; 2013022 Build/HM2013022) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 XiaoMi/MiuiBrowser/2.1.1",
        "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-CN; HM NOTE 1LTE Build/KTU84P) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.2.0.535 U3/0.8.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-CN; HM NOTE 1LTE Build/KTU84P) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.1.0.527 U3/0.8.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.6 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTE Build/KTU84P) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.4 TBS/025410 Mobile Safari/533.1 MicroMessenger/6.1.0.40_r1018582.540 NetType/WIFI",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; MI 2S Build/JRO03L) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 MicroMessenger/6.0.2.58_r984381.520 NetType/WIFI",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTETD Build/KTU84P) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.5 Mobile Safari/533.1 MicroMessenger/6.0.0.54_r849063.501 NetType/WIFI",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTETD Build/KTU84P) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baiduboxapp/6.1 (Baidu; P1 4.4.4)",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTETD Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.5 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-CN; HM NOTE 1LTETD Build/KTU84P) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/9.9.7.500 U3/0.8.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HM NOTE 1LTETD Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 XiaoMi/MiuiBrowser/2.0.1",
        "Mozilla/5.0 (Linux; Android 4.4.4; M351 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 MicroMessenger/6.0.0.50_r844973.501 NetType/WIFI",
        "Mozilla/5.0 (Linux; U; Android 4.2.2; zh-cn; Q3迷你版 Build/JDQ39) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baiduboxapp/5.3.5 (Baidu; P1 4.2.2)",
        "Mozilla/5.0 (Linux; Android 4.4.4; Hisense E621T Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 baiduboxapp/5.0 (Baidu; P1 4.4.4)",
        "Mozilla/5.0 (Linux; U; Android 4.0.4; zh-cn; HS-EG906 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 MicroMessenger/5.3.1.67_r745169.462",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; GT-N7000 Build/IML74K) AppleWebKit/533.1 (KHTML, like Gecko) Mobile MQQBrowser/4.0 Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; M351 Build/KTU84P) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baiduboxapp/6.0 (Baidu; P1 4.4.4)",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-CN; M351 Build/KTU84P) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.9.5.489 U3/0.8.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; M351 Build/KTU84P) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; Android 4.2.1; M040 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36 OPR/20.0.1396.72047",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-CN; M040 Build/JOP40D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.6.0.378 U3/0.8.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baidubrowser/4.3.16.2 (Baidu; P1 4.2.1)",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baiduboxapp/5.1 (Baidu; P1 4.2.1)",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.0 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 baidubrowser/4.2.9.2 (Baidu; P1 4.2.1)",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baidubrowser/4.1.3.1 (Baidu; P1 4.2.1)",
        "Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; M040 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 Maxthon/4.1.3.2000",
        "Mozilla/5.0 (Linux; Android 4.2.1; M040 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-CN; M040 Build/JRO03H) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.4.1.362 U3/0.8.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; Android 4.1.1; M040 Build/JRO03H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; Android 4.1.1; M040 Build/JRO03H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.64 Mobile Safari/537.36",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; M040 Build/JRO03H) AppleWebKit/534.24 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.24 T5/2.0 baidubrowser/4.2.4.0 (Baidu; P1 4.1.1)",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; M031 Build/JRO03H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-CN; M031 Build/JRO03H) AppleWebKit/534.31 (KHTML, like Gecko) UCBrowser/8.8.3.278 U3/0.8.0 Mobile Safari/534.31",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; M040 Build/JRO03H) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/4.1 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; M040 Build/JRO03H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3) AppleWebKit/534.31 (KHTML, like Gecko) Chrome/17.0.558.0 Safari/534.31 UCBrowser/2.3.1.257",
        "Mozilla/5.0 (Linux; U; Android 3.2; zh-cn; GT-P6200 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M031 Build/IML74K) AppleWebKit/530.17 (KHTML, like Gecko) FlyFlow/2.3 Version/4.0 Mobile Safari/530.17 baidubrowser/023_1.41.3.2_diordna_069_046/uzieM_51_3.0.4_130M/1200a/963E77C7DAC3FA587DF3A7798517939D%7C408994110686468/1",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/530.17 (KHTML, like Gecko) FlyFlow/2.3 Version/4.0 Mobile Safari/530.17 baidubrowser/042_1.6.3.2_diordna_008_084/IEWAUH_01_5.3.2_0088U/1001a/BE44DF7FABA8768B2A1B1E93C4BAD478%7C898293140340353/1",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 4.0.4; zh-cn; HTC S720e Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.0.4; zh-cn; HTC S720e Build/IMM76D) UC AppleWebKit/534.31 (KHTML, like Gecko) Mobile Safari/534.31",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M031 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "MQQBrowser/4.0/Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M031 Build/IML74K) AppleWebKit/533.1 (KHTML, like Gecko) Mobile Safari/533.1",
        "MQQBrowser/3.7/Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M9 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M9 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "MQQBrowser/3.5/Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M9 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M031 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "MQQBrowser/3.7/Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn) AppleWebKit/530.17 (KHTML, like Gecko) FlyFlow/2.2 Version/4.0 Mobile Safari/530.17",
        "Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; U8800 Build/HuaweiU8800) UC AppleWebKit/534.31 (KHTML, like Gecko) Mobile Safari/534.31",
        "Mozilla/5.0 (Linux; Android 4.0.3; M031 Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
        "Opera/9.80 (Android 4.0.3; Linux; Opera Mobi/ADR-1210241511) Presto/2.11.355 Version/12.10",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M031 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn) AppleWebKit/530.17 (KHTML, like Gecko) FlyFlow/2.2 Version/4.0 Mobile Safari/530.17",
        "Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; M031 Build/IML74K) UC AppleWebKit/534.31 (KHTML, like Gecko) Mobile Safari/534.31"
 
    ]
    headers = random.choice(uaList)
    return headers
 
word_dict = {
        "北京房价":{'domain':'taofang.com','all_count':5,'count':0},
        "上海房价":{'domain':'taofang.com','all_count':5,'count':0},
        "北京奥迪二手车":{'domain':'baixing.com','all_count':5,'count':0},
        "北京奥迪二手车交易市场":{'domain':'sohu.com','all_count':5,'count':0},
    }
 
'''domain出现在第一页,则根据排名指定如下点击顺序'''
click_list_rank1 = {
    1:[1],
    2:[1,2],
    3:['%s' % random.randint(1,2),3] ,
    4:['%s' % random.randint(1,3),4],
    5:['%s' % random.randint(1,4),5],
    6:['%s' % random.randint(1,5),6],
    7:['%s' % random.randint(1,6),7],
    8:['%s' % random.randint(1,7),8],
    9:['%s' % random.randint(1,8),9],
    10:['%s' % random.randint(1,9),10],
    11:['%s' % random.randint(1,5),'%s' % random.randint(6,10),11],
    12:['%s' % random.randint(1,5),'%s' % random.randint(6,11),12],
    13:['%s' % random.randint(1,5),'%s' % random.randint(6,12),13],
    14:['%s' % random.randint(1,5),'%s' % random.randint(6,13),14],
    15:['%s' % random.randint(1,5),'%s' % random.randint(6,14),15],
    16:['%s' % random.randint(1,10),'%s' % random.randint(11,15),16],
    17:['%s' % random.randint(1,10),'%s' % random.randint(11,16),17],
    18:['%s' % random.randint(1,10),'%s' % random.randint(11,17),18],
    19:['%s' % random.randint(1,10),'%s' % random.randint(11,18),19],
    20:['%s' % random.randint(1,10),'%s' % random.randint(11,19),20]
}
 
def word_list():
    word_list = word_dict.keys()
    word = random.choice(word_list)
    return word
 
def wait():
    return random.uniform(20,60) 
 
def export():
    export_ip = re.search(r'\d+\.\d+\.\d+\.\d+',urllib2.urlopen("http://www.whereismyip.com").read()).group(0)
    return export_ip
 
'''adsl切换出口ip'''
g_adsl_account = {"name": "ADSL",
                "username": "99392213",
                "password": "123456"}
 
'''adsl拨号'''
class Adsl(object):
    def __init__(self):
        self.name = g_adsl_account["name"]
        self.username = g_adsl_account["username"]
        self.password = g_adsl_account["password"]
 
    def set_adsl(self, account):
        self.name = account["name"]
        self.username = account["username"]
        self.password = account["password"]
 
    def connect(self):
        cmd_str = "rasdial %s %s %s" % (self.name, self.username, self.password)
        os.system(cmd_str)
        time.sleep(5)
 
    def disconnect(self):
        cmd_str = "rasdial %s /disconnect" % self.name
        os.system(cmd_str)
        time.sleep(5)
 
    def reconnect(self):
        self.disconnect()
        self.connect()
 
for ip in open('hege_daili.txt'):
    if ip.strip in myProxy_list:
        continue
    else:
        myProxy_list.append(ip)
 
        newip = ip.strip()
 
    '''加载代理ip'''
    proxy = Proxy({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': newip,
        'ftpProxy': newip,
        'sslProxy': newip,
        'noProxy': '' # set this value as desired
        })
 
    useragent = getUA()
 
    '''加载代理,写入配置文件'''
    profile = webdriver.FirefoxProfile()
    profile.set_preference("general.useragent.override","%s" % useragent)  
 
    '''打开浏览器窗口'''
    # browser = webdriver.Firefox(profile,proxy=proxy)
    browser = webdriver.Firefox(profile)
 
    try:
        '''设置浏览器窗口'''
        browser.set_window_size(300,800)
    except:
        print '浏览器窗口调整错误,重启浏览器'
        browser.quit()
        continue
 
    word = word_list()
    domain = word_dict[word]['domain']
    all_count = word_dict[word]['all_count']
    count = word_dict[word]['count']
 
    print '>>>>>>>>>>>>>>>>>>开始查询:%s,已点击%s次>>>>>>>>>>>>>>>>>' % (word,count)
 
    if count > all_count:
        print '%s已刷满' % word
        browser.delete_all_cookies()
        browser.quit()
        continue
    else:
        try:
            print 'user agent: %s' % useragent
 
            '''设置30s超时'''
            browser.implicitly_wait(10)
 
            browser.get("http://m.baidu.com")
            time.sleep(1)
 
            '''定位input元素'''
            # browser.find_element_by_id("index-kw").send_keys(word.decode('utf-8'))
 
            input_element_list = ['index-kw','word']
            for input_element in input_element_list:
                try:
                    browser.find_element_by_id("%s" % input_element).is_displayed()
                except:
                    print '未找到%s,开始查找下一个input元素' % input_element
                else:
                    #print '%s元素存在,跳出循环' % input_element
                    input_dw = input_element
                    break
 
            #print 'input'
            browser.find_element_by_id("%s" % input_dw).send_keys(word.decode('utf-8'))
 
            '''定位click元素'''
            #browser.find_element_by_id("index-bn").click()
 
            click_element_list = ['index-bn:id','ct_2:name']
            for click_element_trem in click_element_list:
                click_element = click_element_trem.split(':')[0]
                method = click_element_trem.split(':')[1]
 
                try:
                    if method == 'id':
                        browser.find_element_by_id("%s" % click_element).is_displayed()
                    else:
                        browser.find_element_by_name("%s" % click_element).is_displayed()
                except:
                    print '未找到%s,开始查找下一个input元素' % click_element
                else:
                    #print '%s元素存在,跳出循环' % click_element
                    click_dw_trem = click_element_trem
                    break
 
            time.sleep(1)
 
            #print 'click'
            if click_dw_trem.split(':')[1] == 'id':
                browser.find_element_by_id("%s" % click_dw_trem.split(':')[0]).click()
            else:
                browser.find_element_by_name("%s" % click_dw_trem.split(':')[0]).click()
 
            '''暂停1s'''
            time.sleep(1)
 
            '''定位搜索结果块级元素'''
            #number = len(browser.find_elements_by_class_name("result"))
            block_element_list = ['result','resitem']
            for block_element in block_element_list:
                try:
                    browser.find_element_by_class_name("%s" % block_element).is_displayed()
                    time.sleep(1)
                except:
                    print '未找到%s,开始查找下一个搜索结果块元素' % block_element
                else:
                    #print '%s元素存在,跳出循环' % block_element
                    block_dw = block_element
                    break
 
            #print 'serp analytics'
            number = len(browser.find_elements_by_class_name("%s" % block_dw))
            #print '%s,%s' % (word,number)
 
            '''查看当前关键词是或否在第一页出现'''
            #print '查看关键词第一页是否出现'
            verify = 'no'
            rank = 0
            for i in range(1,number):
                lines = browser.find_elements_by_class_name("%s" % block_dw)
                rank += 1
                if domain in lines[i].text:
                    verify = 'yes'
                    break
                else:
                    continue
 
            '''if判定,根据domain是否在第一页出现,执行不同动作'''
            if verify == 'yes':
                print '排在第一页,点击第一页结果'
                print '%s , rank one page , rank is %s' % (word,rank)
 
                for i in click_list_rank1[rank]:
 
                    print '%s rank is %s , domain is %s , new click is result %s' % (word,rank,domain,i)
 
                    b_tags = browser.find_elements_by_class_name("%s" % block_dw)
                    tags = b_tags[int(i)]
 
                    browser.implicitly_wait(10)
                    tags.find_element_by_tag_name("a").click()
                    time.sleep(5)
                    browser.back()
 
                    if i == rank:
                        word_dict[word]['count'] = count + 1
                        print '%s , succeed click %s num' % (word,word_dict[word]['count'])
 
            else:
                '''检测分页特征'''
                #print '检测第二页是否包含排名,开始点击下一页,进入第二页'
                browser.find_element_by_id('pagenav').click()
                time.sleep(3)
 
                number = len(browser.find_elements_by_class_name("%s" % block_dw))
                rank = 0
                for i in range(1,number):
                    lines = browser.find_elements_by_class_name("%s" % block_dw)
                    rank += 1
                    if domain in lines[i].text:
                        verify = 'yes'
                        break
                    else:
                        continue
 
                if verify == 'yes':
                    print '已确认排名第二页'
                    print '%s , rank one page , rank is %s' % (word,rank)
 
                    for i in click_list_rank1[rank]:
 
                        print '%s rank is %s , domain is %s , new click is result %s' % (word,rank,domain,i)
                        browser.find_element_by_id('pagenav').click()
                        time.sleep(3)
                        b_tags = browser.find_elements_by_class_name("%s" % block_dw)
                        tags = b_tags[int(i)]
 
                        browser.implicitly_wait(10)
                        tags.find_element_by_tag_name("a").click()
                        time.sleep(5)
                        browser.back()      
 
                        if i == rank:
                            word_dict[word]['count'] = count + 1
                            print '%s , succeed click %s num' % (word,word_dict[word]['count']) 
 
                else:
                    print 'word不在前两页,放弃点击'
                    browser.delete_all_cookies()
                    browser.quit()
                    continue
 
        except:
            print 'error'
            browser.delete_all_cookies()
            browser.quit()
            continue
 
    browser.delete_all_cookies()
    browser.quit()
 
    '''执行adsl拨号'''
    # export = Adsl()
    # export.reconnect()
 
    sleep = int(wait())
    print '>>>>>>>>>等待%ss>>>>>>>>>' % sleep
    time.sleep(sleep)

理论篇
刷点击那点事:点击一下,你就知道
@夜息哥哥喊我在圣诞节更新,我怎敢不从,吓得我赶紧屁颠屁颠的下班回家乖乖码字~~~

说来也怪,最近关于刷点击相关的话题出现在各种群里,恰巧,我之前用python写过一个点击器的Demo,最后一次花了1-2天测试几个排在第二、三页的词,大部分都跑到了第一页,也不知道是点上去的还是自然上去的……但是下拉框确实是刷出来了,之前在百度搜“gogo”的时候,下拉框是出现了我的网名“GoGo闯”的。

虽然没有专门做这个,也没有再深入研究,但当时写点击器的过程还是可以扯一扯。

先说为何要刷点击,先解释下,之所以有刷点击的需求,是因为在搜索引擎中,一个网页的点击率是影响该网页在搜索结果中排序的因素之一,且这个因素相对其他因素更容易控制一些,所以肯定有人希望人为控制这个因素来提高网页在搜索引擎中的排名。

于是当时下载了几个点击软件瞅了瞅,这些软件大多分挂机部分和点击部分。挂机部分把软件下载到本地,然后控制本地浏览器去点击别人指定关键词对应的网页,点击一次给予一定的积分;点击部分就是你设置要别人点击的网页,那些正在挂机的机子就会点击这个词,被点击一次扣除一定的积分。所以想要获得点击,就要有积分,想要有积分就要多多挂机去点别人的词,依此循环。

这些点击均来自不同用户的浏览器触发,看起来都是真实的点击。照此看,只要能控制浏览器并用不同的IP进行符合用户行为规律的点击,就可以实现那些点击软件的功能。

所以用python的selenium来控制本地浏览器,每点击一次,清空cookie、关闭浏览器、切换IP、切换UA,再次点击,且每一个步骤包含多种策略,使之更加符合用户的行为,而不是机器的行为。

ps:selenium是调用本地浏览器,执行的时候浏览器窗口一会开一会关,是没法干别的活的,要像类似后台运行,还需要phantomjs,调用浏览器内核(可以理解为使用浏览器,但不打开浏览器窗口)来访问。但有时,本地浏览器定位指定元素的xpath路径,换了phantomjs是定位不到的,通常本地浏览器换个版本就行了,或者换另一个本地浏览器试下~~

先说IP。要专门搞这个,那肯定要有大量的IP资源,要模拟百度用户点击,首先IP得是全国范围的、在不同的频段,且IP以往在搜索引擎中的行为是正常的。所以搞了几台能支持全国adsl拨号的机子,点一次,断线重连换ip。

再说一下点击行为。提前查了一些词的排名,挑了一些排在第2、3页的网页作为要点击的网页。正常用户的在搜索引擎的浏览行为,是先点击搜索结果第一页的几个网页,没找到满意的,在“下一页”,点击2、3页的结果,找到满意的结果后,关闭网页,退出搜索引擎。

所以,个人觉得,把要刷的网页,作为最后一次点击,搜索引擎可能会认为,这个网页在一定概率上是用户想要的结果,满意了,所以退出搜索引擎,会先提高在结果中的排序,在根据该页面后续的点击频率/最后一次点击,决定是否长时间留在第一页。

所以我把整个程序的点击行为设置为:先找到目标网页的具体位置,在随机点击前面的几个网页,分别停留一段时间,最后在点击目标网页,然后退出搜索引擎。
字典
再说下防止搜索引擎识别假点击(以下是我拍脑门的)。在单个点击上,符合大多用的点击行为,也就是上面说的,否则上来直接点击第二页的结果这太假了。在所有点击上,各种用户属性的比例是正常的,这里指用户IP地理位置的比例、浏览器的比例、操作系统的比例、被点击次数与关键词搜索量的比例……

比如移动搜索,假设Android和IOS比例为1:1,而刷的页面全部设置的IOS访问,这就算比例不正常。其他的属性都以此类推。

期间还发现了一个情况,如果是在PC端控制浏览器点击,且刷的是wap页面,那么百度统计记录的屏幕分辨率是PC的分辨率,这个特征是很明显的,但暂时没有找到伪装移动屏幕分辨率的办法。

另外,如果用市面上的点击软件去刷,可能基本没有效果。因为一个软件,刷点击所用的IP总是来自于固定范围的一些用户(既经常使用挂机软件的那些用户),一方面搜索引擎会容易的获取这些用户的IP并加黑,另一方面,很多这种软件出于投入产出比的考虑,取消挂机给积分的措施,而改用充值给积分的方式快速捞钱,所以来自真实用户的IP会越来越少。

也跟一个做点击的人请教过IP获取的问题,但他原来是做IDC的,从来不知道缺IP是一种什么样的体验 -_-!

要是一个企业站,想把某几个有商业价值的词做上去,刷一刷我觉得还是可以的。要是有品牌负面信息压制的需求,想把无负面信息的网页搞上来,刷一刷我觉得还是可以的。但一个上稍有些规模的站在搞这个,个人觉得就有些丢西瓜捡芝麻了,分不清哪个是西瓜,哪个是芝麻的感觉了。好好做内容,好好做结构,才是西瓜~~

最后,当时写点击器纯属出于想折腾一下的目的心血来潮搞了一个粗糙的demo,但对这块业务没任何兴趣,在深入的我也不了解,所以也不用问我什么东西。至于demo的代码,我博客里挂着了(点击“原文链接”),要参考拿走便是。

重要事情说三遍
【GOGO闯】微信公众号:流量贩子
【GOGO闯】微信公众号:流量贩子
【GOGO闯】微信公众号:流量贩子

发表评论

电子邮件地址不会被公开。