import requests
import random
import re
import time
from multiprocessing import Pool

proxy_list = ['221.205.19.59:8080', '174.138.69.29:8080', '42.81.11.22:8080', '183.230.177.170:8081',
              '185.100.226.149:8081', '198.50.219.239:8080', '5.2.69.137:1080', '181.15.156.190:8080',
              '125.215.250.65:808', '203.201.175.254:8080', '186.42.121.150:80', '171.10.31.41:8080',
              '222.94.151.54:808', '89.40.115.161:1189', '216.100.88.228:8080', '27.100.36.190:80', '59.126.48.8:8080',
              '61.130.97.212:8099', '54.187.52.159:8080', '13.124.9.190:80', '109.197.184.27:8080', '91.194.42.51:80',
              '54.187.52.159:80', '218.205.114.221:80', '121.232.146.81:9000', '125.141.132.118:80',
              '117.90.6.239:9000', '1.61.245.127:8118', '124.133.230.254:80', '115.215.50.154:8118', '88.82.86.54:8081',
              '38.96.9.226:8008', '80.55.86.174:8080', '14.122.196.239:9000', '54.179.166.238:8080',
              '165.138.124.4:8080', '121.227.110.120:8118', '202.59.74.190:808', '121.41.175.199:80',
              '95.79.41.94:8081', '128.199.192.252:80', '163.47.11.113:8080', '195.208.146.198:8081', '131.0.246.92:80',
              '106.2.184.227:80', '144.217.188.52:8080', '46.44.46.241:8081', '66.175.83.156:8080',
              '121.232.145.124:9000', '60.184.174.14:808', '179.105.160.101:8080', '101.4.136.34:8080',
              '121.232.147.15:9000', '122.96.59.106:82', '203.112.211.106:8080', '207.154.209.54:80',
              '119.130.24.74:8888', '121.232.146.120:9000', '149.56.232.21:8080', '54.179.166.238:443',
              '139.59.244.147:8080', '78.24.41.100:8081', '138.201.194.15:8150', '188.166.217.2:8888',
              '37.204.158.83:8081', '46.39.238.113:8081', '223.156.85.70:80', '121.43.227.212:808',
              '101.67.59.250:8118', '58.154.33.12:8080', '62.255.38.187:8080', '58.217.33.51:8118',
              '27.191.234.69:9999', '111.13.7.117:80', '111.13.7.42:80', '144.217.188.52:8799', '223.86.37.135:8998',
              '64.34.21.84:80', '190.12.102.205:8080', '218.25.37.108:80', '112.194.87.10:9000', '178.32.226.180:80',
              '31.14.133.91:8080', '111.13.7.119:80', '95.47.36.34:53281', '219.153.76.77:8080', '149.56.232.21:80',
              '27.202.180.8:8118', '121.40.108.76:80', '64.183.94.45:8080', '222.95.19.158:808', '42.6.232.245:80',
              '186.42.188.110:53281', '220.161.56.132:8118', '109.121.161.44:53281', '83.166.96.47:8081',
              '121.15.220.61:80', '101.53.101.172:9999', '61.152.81.193:9100', '121.232.146.138:9000',
              '210.35.171.4:8081', '144.217.188.52:80', '121.232.148.37:9000', '88.198.24.108:8080',
              '122.228.25.97:8101', '121.232.146.137:9000', '108.221.32.85:8080', '121.232.144.161:9000',
              '123.134.227.233:80', '189.206.157.177:80', '111.13.7.121:80', '195.80.140.212:8081',
              '163.121.188.2:8080', '111.13.7.120:80', '114.234.81.9:9000', '159.255.163.189:80', '91.73.131.254:8080',
              '219.154.152.81:80', '101.4.136.34:80', '125.67.239.175:8080', '113.93.187.81:808', '183.240.87.229:80',
              '198.11.137.72:80', '182.93.233.238:8080', '87.236.233.182:1080', '116.20.229.148:9797',
              '124.81.212.50:8081', '134.213.221.177:5070', '180.173.109.149:8118', '182.90.55.41:80',
              '117.90.2.58:9000', '193.227.49.83:8080', '107.21.56.41:443', '39.77.58.32:8118', '202.58.205.126:53281',
              '101.200.60.248:80', '116.28.109.64:808', '117.90.3.58:9000', '64.26.152.44:80', '187.44.14.19:8080',
              '14.63.226.198:80', '175.165.101.48:8118', '104.236.144.189:80', '97.73.2.166:87', '178.251.142.178:8081',
              '158.181.16.88:8080', '5.2.69.140:1080', '117.90.5.49:9000', '121.40.144.67:80', '119.29.166.243:1080',
              '162.243.78.25:8080', '185.11.251.134:80', '180.104.62.217:9000', '103.15.251.75:80', '69.7.46.63:80',
              '183.184.144.53:80', '5.2.69.146:1080', '166.111.77.32:80', '198.11.137.71:80', '120.132.71.212:80',
              '122.5.129.236:808', '159.224.83.100:8080', '165.138.79.68:8080', '109.197.188.9:8080', '41.94.8.6:8000',
              '123.57.34.240:80', '221.15.107.150:8118', '220.174.236.211:80', '103.195.55.2:8080',
              '218.106.205.145:8080']

baidu = 'https://www.baidu.com/s?wd=%E8%BF%BD%E5%AF%BB%E8%87%AA%E6%88%91%E7%9A%84%E6%97%85%E9%80%94&rsv_spt=1&rsv_iqid=0xa6a84d180000dcd0&issp=1&f=8&rsv_bp=0&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_sug3=19&rsv_sug1=10&rsv_sug7=100&rsv_sug2=0&inputT=5326&rsv_sug4=5326&rsv_sug=2'
referers = ['http://blog.sina.com.cn/u/1300871220', 'http://blog.sina.com.cn/u/1300871220',
            'http://blog.sina.com.cn/u/1216826604', 'http://blog.sina.com.cn/u/1216826604',
            'http://blog.sina.com.cn/u/1245296155', 'http://blog.sina.com.cn/u/1245296155',
            'http://blog.sina.com.cn/u/1284139322', 'http://blog.sina.com.cn/u/1284139322',
            'http://blog.sina.com.cn/u/1285707277', 'http://blog.sina.com.cn/u/1285707277',
            'http://blog.sina.com.cn/u/1458594614', 'http://blog.sina.com.cn/u/1458594614',
            'http://blog.sina.com.cn/u/1236135807', 'http://blog.sina.com.cn/u/1236135807',
            'http://blog.sina.com.cn/u/1191258123', 'http://blog.sina.com.cn/u/1191258123',
            'http://blog.sina.com.cn/u/1504965870', 'http://blog.sina.com.cn/u/1504965870',
            'http://blog.sina.com.cn/u/1220824437', 'http://blog.sina.com.cn/u/1220824437',
            'http://blog.sina.com.cn/u/1292400222', 'http://blog.sina.com.cn/u/1292400222',
            'http://blog.sina.com.cn/u/1298535315', 'http://blog.sina.com.cn/u/1298535315',
            'http://blog.sina.com.cn/u/1279884602', 'http://blog.sina.com.cn/u/1279884602',
            'http://blog.sina.com.cn/u/1364334665', 'http://blog.sina.com.cn/u/1364334665',
            'http://blog.sina.com.cn/u/1254470047', 'http://blog.sina.com.cn/u/1254470047',
            'http://blog.sina.com.cn/u/1189591617', 'http://blog.sina.com.cn/u/1189591617',
            'http://blog.sina.com.cn/u/1190363061', 'http://blog.sina.com.cn/u/1190363061',
            'http://blog.sina.com.cn/u/1246792191', 'http://blog.sina.com.cn/u/1246792191',
            'http://blog.sina.com.cn/u/1347712670', 'http://blog.sina.com.cn/u/1347712670',
            'http://blog.sina.com.cn/u/1265722751', 'http://blog.sina.com.cn/u/1265722751',
            'http://blog.sina.com.cn/u/1145642397', 'http://blog.sina.com.cn/u/1145642397',
            'http://blog.sina.com.cn/u/1278228085', 'http://blog.sina.com.cn/u/1278228085',
            'http://blog.sina.com.cn/u/1233526741', 'http://blog.sina.com.cn/u/1233526741',
            'http://blog.sina.com.cn/u/1243037810', 'http://blog.sina.com.cn/u/1243037810',
            'http://blog.sina.com.cn/u/1319231304', 'http://blog.sina.com.cn/u/1319231304',
            'http://blog.sina.com.cn/u/1456252804', 'http://blog.sina.com.cn/u/1456252804',
            'http://blog.sina.com.cn/u/1225899402', 'http://blog.sina.com.cn/u/1225899402',
            'http://blog.sina.com.cn/u/1243881594', 'http://blog.sina.com.cn/u/1243881594',
            'http://blog.sina.com.cn/u/1420174783', 'http://blog.sina.com.cn/u/1420174783',
            'http://blog.sina.com.cn/u/1364616083', 'http://blog.sina.com.cn/u/1364616083',
            'http://blog.sina.com.cn/u/1282871591', 'http://blog.sina.com.cn/u/1282871591',
            'http://blog.sina.com.cn/u/1233227211', 'http://blog.sina.com.cn/u/1233227211',
            'http://blog.sina.com.cn/u/1191211465', 'http://blog.sina.com.cn/u/1191211465',
            'http://blog.sina.com.cn/u/1197950454', 'http://blog.sina.com.cn/u/1197950454',
            'http://blog.sina.com.cn/u/1223299212', 'http://blog.sina.com.cn/u/1223299212',
            'http://blog.sina.com.cn/u/1279916282', 'http://blog.sina.com.cn/u/1279916282',
            'http://blog.sina.com.cn/u/1266020172', 'http://blog.sina.com.cn/u/1266020172',
            'http://blog.sina.com.cn/u/1188552450', 'http://blog.sina.com.cn/u/1188552450',
            'http://blog.sina.com.cn/u/1368179347', 'http://blog.sina.com.cn/u/1368179347',
            'http://blog.sina.com.cn/u/1096536995', 'http://blog.sina.com.cn/u/1096536995',
            'http://blog.sina.com.cn/u/1228293531', 'http://blog.sina.com.cn/u/1228293531',
            'http://blog.sina.com.cn/u/1223841312', 'http://blog.sina.com.cn/u/1223841312',
            'http://blog.sina.com.cn/u/1319802272', 'http://blog.sina.com.cn/u/1319802272',
            'http://blog.sina.com.cn/u/1420555367', 'http://blog.sina.com.cn/u/1420555367',
            'http://blog.sina.com.cn/u/1481028245', 'http://blog.sina.com.cn/u/1481028245',
            'http://blog.sina.com.cn/u/1288557173', 'http://blog.sina.com.cn/u/1288557173',
            'http://blog.sina.com.cn/u/1257495952', 'http://blog.sina.com.cn/u/1257495952',
            'http://blog.sina.com.cn/u/1215172700', 'http://blog.sina.com.cn/u/1215172700',
            'http://blog.sina.com.cn/u/1633662514', 'http://blog.sina.com.cn/u/1633662514',
            'http://blog.sina.com.cn/u/1305431810', 'http://blog.sina.com.cn/u/1305431810',
            'http://blog.sina.com.cn/u/1414660444', 'http://blog.sina.com.cn/u/1414660444',
            'http://blog.sina.com.cn/u/1198251274', 'http://blog.sina.com.cn/u/1198251274',
            'http://blog.sina.com.cn/u/1025708803', 'http://blog.sina.com.cn/u/1025708803',
            'http://blog.sina.com.cn/u/1236617023', 'http://blog.sina.com.cn/u/1236617023',
            'http://blog.sina.com.cn/u/1189615035', 'http://blog.sina.com.cn/u/1189615035',
            'http://blog.sina.com.cn/u/1249424622', 'http://blog.sina.com.cn/u/1249424622',
            'http://blog.sina.com.cn/u/1494856974', 'http://blog.sina.com.cn/u/1494856974',
            'http://blog.sina.com.cn/u/1192230491', 'http://blog.sina.com.cn/u/1192230491',
            'http://blog.sina.com.cn/u/1258205462', 'http://blog.sina.com.cn/u/1258205462',
            'http://blog.sina.com.cn/u/1248272901', 'http://blog.sina.com.cn/u/1248272901',
            'http://blog.sina.com.cn/u/1213332190', 'http://blog.sina.com.cn/u/1213332190',
            'http://blog.sina.com.cn/u/1320219435', 'http://blog.sina.com.cn/u/1320219435',
            'http://blog.sina.com.cn/u/1336750060', 'http://blog.sina.com.cn/u/1336750060',
            'http://blog.sina.com.cn/u/1272933544', 'http://blog.sina.com.cn/u/1272933544',
            'http://blog.sina.com.cn/u/1286664381', 'http://blog.sina.com.cn/u/1286664381',
            'http://blog.sina.com.cn/u/1033436027', 'http://blog.sina.com.cn/u/1033436027',
            'http://blog.sina.com.cn/u/1307309734', 'http://blog.sina.com.cn/u/1307309734',
            'http://blog.sina.com.cn/u/1346553137', 'http://blog.sina.com.cn/u/1346553137',
            'http://blog.sina.com.cn/u/1246151574', 'http://blog.sina.com.cn/u/1246151574',
            'http://blog.sina.com.cn/u/1571875947', 'http://blog.sina.com.cn/u/1571875947',
            'http://blog.sina.com.cn/u/1199712261', 'http://blog.sina.com.cn/u/1199712261',
            'http://blog.sina.com.cn/u/1419092951', 'http://blog.sina.com.cn/u/1419092951',
            'http://blog.sina.com.cn/u/1569548481', 'http://blog.sina.com.cn/u/1569548481',
            'http://blog.sina.com.cn/u/1270344441', 'http://blog.sina.com.cn/u/1270344441',
            'http://blog.sina.com.cn/u/1302676937', 'http://blog.sina.com.cn/u/1302676937',
            'http://blog.sina.com.cn/u/1354128900', 'http://blog.sina.com.cn/u/1354128900',
            'http://blog.sina.com.cn/u/1345654037', 'http://blog.sina.com.cn/u/1345654037',
            'http://blog.sina.com.cn/u/1289997621', 'http://blog.sina.com.cn/u/1289997621',
            'http://blog.sina.com.cn/u/1639802725', 'http://blog.sina.com.cn/u/1639802725',
            'http://blog.sina.com.cn/u/1249159055', 'http://blog.sina.com.cn/u/1249159055',
            'http://blog.sina.com.cn/u/1362607654', 'http://blog.sina.com.cn/u/1362607654',
            'http://blog.sina.com.cn/u/1195201334', 'http://blog.sina.com.cn/u/1195201334',
            'http://blog.sina.com.cn/u/1396812534', 'http://blog.sina.com.cn/u/1396812534',
            'http://blog.sina.com.cn/u/1338707944', 'http://blog.sina.com.cn/u/1338707944',
            'http://blog.sina.com.cn/u/1224361860', 'http://blog.sina.com.cn/u/1224361860',
            'http://blog.sina.com.cn/u/1198920804', 'http://blog.sina.com.cn/u/1198920804',
            'http://blog.sina.com.cn/u/1195403385', 'http://blog.sina.com.cn/u/1195403385',
            'http://blog.sina.com.cn/u/1288109750', 'http://blog.sina.com.cn/u/1288109750',
            'http://blog.sina.com.cn/u/1210558317', 'http://blog.sina.com.cn/u/1210558317',
            'http://blog.sina.com.cn/u/1299345257', 'http://blog.sina.com.cn/u/1299345257',
            'http://blog.sina.com.cn/u/1236937620', 'http://blog.sina.com.cn/u/1236937620',
            'http://blog.sina.com.cn/u/1253531973', 'http://blog.sina.com.cn/u/1253531973',
            'http://blog.sina.com.cn/u/1156966391', 'http://blog.sina.com.cn/u/1156966391',
            'http://blog.sina.com.cn/u/1285846970', 'http://blog.sina.com.cn/u/1285846970',
            'http://blog.sina.com.cn/u/1198367585', 'http://blog.sina.com.cn/u/1198367585',
            'http://blog.sina.com.cn/u/1514551012', 'http://blog.sina.com.cn/u/1514551012',
            'http://blog.sina.com.cn/u/1223537940', 'http://blog.sina.com.cn/u/1223537940',
            'http://blog.sina.com.cn/u/1195031270', 'http://blog.sina.com.cn/u/1195031270',
            'http://blog.sina.com.cn/u/1278127565', 'http://blog.sina.com.cn/u/1278127565',
            'http://blog.sina.com.cn/u/1288814951', 'http://blog.sina.com.cn/u/1288814951']


def getUrl(referer):
    url = [
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj99&ref={}&varname=requestId_8163105',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjqa&ref={}&varname=requestId_8640991',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjq9&ref={}&varname=requestId_2160121',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4v&ref={}&varname=requestId_9480556',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4r&ref={}&varname=requestId_7481746',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4t&ref={}&varname=requestId_8701622',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wiwm&ref={}&varname=requestId_7082901',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4r&ref={}&varname=requestId_8221396',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj2o&ref={}&varname=requestId_8580399',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wizs&ref={}&varname=requestId_1291354',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjhc&ref={}&varname=requestId_4253049',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wirr&ref={}&varname=requestId_6294629',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj71&ref={}&varname=requestId_3261146',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wiwm&ref={}&varname=requestId_1994092',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wivu&ref={}&varname=requestId_5618386',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4t&ref={}&varname=requestId_6179653',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4w&ref={}&varname=requestId_4622845',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj71&ref={}&varname=requestId_2595881',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjpt&ref={}&varname=requestId_6293496',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjq1&ref={}&varname=requestId_1661619',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjq1&ref={}&varname=requestId_4865008',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4p&ref={}&varname=requestId_5367785',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wiu5&ref={}&varname=requestId_3285863',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjpo&ref={}&varname=requestId_8236467',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj45&ref={}&varname=requestId_4982688',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4w&ref={}&varname=requestId_8541361',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj73&ref={}&varname=requestId_3421371',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wirr&ref={}&varname=requestId_5978978',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj1v&ref={}&varname=requestId_8075896',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj9a&ref={}&varname=requestId_6217699',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj99&ref={}&varname=requestId_7201000',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4t&ref={}&varname=requestId_8652967',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjpo&ref={}&varname=requestId_3609305',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjq9&ref={}&varname=requestId_1743548',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjq1&ref={}&varname=requestId_4643470',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjq8&ref={}&varname=requestId_6334563',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4p&ref={}&varname=requestId_6107484',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjhf&ref={}&varname=requestId_6759254',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjhd&ref={}&varname=requestId_2898275',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wp01&ref={}&varname=requestId_8377588',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wp01&ref={}&varname=requestId_6303028',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj45&ref={}&varname=requestId_3544825',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj4w&ref={}&varname=requestId_1455306',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjhe&ref={}&varname=requestId_4794491',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wiu5&ref={}&varname=requestId_5234721',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wiwm&ref={}&varname=requestId_7505278',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wj98&ref={}&varname=requestId_1502941',
        'http://comet.blog.sina.com.cn/api?maintype=hits&act=4&aid=1545beda90102wjhd&ref={}&varname=requestId_9839171']
    return random.choice(url).format(referer)


def view(i):
    try:
        ip = random.choice(proxy_list)
        referer = random.choice(referers)
        headers = {
            'Referer': referer,
        }
        ip = "http://{}".format(ip)
        proxies = {'http': ip}
        url = getUrl(referer)
        wb_date = requests.get(url, headers=headers, proxies=proxies)

    except:
        pass


if __name__ == '__main__':
    pool = Pool()
    pool = Pool(processes=30)
    pool.map(view, range(2000000))
