• IGXE搬砖项目


    主要的赚钱方式和倒爷其实是差不多的,自动检测igxe平台上价格与buff相差8.5%以上的饰品,按照历史价格进行一定的过滤,防止翻车,然后自动购买。

    2019年经历了十几次的改进以对抗同行的脚本,到11月末确实干不过了,就搁置了。差不多历经8个月,赚了有4w吧。前3个月还是半自动的,后面就改成了全自动。

    主要是一开始对自己做的脚本没有信心,怕出bug,经过几个月的测试,有了初步的了解,同时也因为同行速度越来越快,就改为全自动。以下是用python做的脚本,因为python的可移植性属实8行,在其他人的电脑大概率跑不起来。这边我也分享环境。

    链接:点这里

    提取码:qne6

    这是我初学python瞎鸡巴敲的项目,仅供参考。

    用于收集URL数据的程序源码

     1 # coding:utf-8
     2 import requests
     3 import json
     4 from datetime import datetime
     5 import re
     6 import threading
     7 import time
     8 import os
     9 import urllib3
    10 from appium import webdriver as appwebdriver
    11 import itchat
    12 from selenium import webdriver
    13 from selenium.webdriver import ActionChains
    14 from selenium.webdriver.common.keys import Keys
    15 from itchat.content import *
    16 import smtplib
    17 from email.mime.text import MIMEText
    18 cookie ='''_ga=GA1.2.1825115838.1564985594; _ntes_nnid=9fb57abcfe13da07759ef54dfce1cf16,1565253919812; _ntes_nuid=9fb57abcfe13da07759ef54dfce1cf16; _gid=GA1.2.1661889417.1566449941; csrf_token=0f98e3f72a0eaa1d3def6557d1698f85c800bb06; game=csgo; _gat_gtag_UA_109989484_1=1; NTES_YD_SESS=mcVtvffuy1B3w_9rE2sUoD7SNzipZpq2_LeArKiEwwfjhziQhoRng7oYaG0u4HhWmRO1rhdsM3r5DjipxqTBQCdqptEedKSlrKtuLtVns8T8LPbfCTEDhSAE33hFxp1dXtMZc7fDeaX5UIzJgcpB7mSTS46SPt7jYZUb5XdgDggD_nkur8JKLGab50GhHqqwExRDIsFL_pmdFxLRmEtG.mA4FqUZXa3Gc0MYwL4AiC6qu; S_INFO=1566483995|0|3&80##|13144266321; P_INFO=13144266321|1566483995|1|netease_buff|00&99|gud&1566451144&netease_buff#gud&440500#10#0#0|&0|null|13144266321; session=1--yGMiLNMb_mjeVKQzv-3wdWQ5SG93aZxYcUK9sbI1URH2045887594; Locale-Supported=zh-Hans'''
    19 #手动从谷歌浏览器中的netword获取cookie,复制粘贴
    20 header = {
    21 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
    22 'Connection': 'keep-alive',
    23 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    24 'Cookie': cookie
    25 }
    26 def getbuffdatagunsurl():
    27     z = open('buffdataknife2', 'w', encoding='utf-8') ##################
    28     for i in range(1,83):   ##################
    29         url = "https://buff.163.com/api/market/goods?game=csgo&page_num="+str(i)+"&category_group=knife&_=1566484015091" ###############
    30         #print(url)
    31         point = requests.get(url, headers=header, timeout=5)
    32         turn = point.content.decode(encoding='gbk', errors='ignore')
    33         res = json.loads(turn)
    34         for i in res['data']['items']:
    35             content = {}
    36             content['价格']=i['sell_min_price']
    37             content['goodid']=i['id']
    38             content['name']=i['name']
    39             if float(content['价格'])>200 :
    40                 goodsid =str(content['goodid'])
    41                 itemname  = content['name'].replace(" ","")
    42                 hisurl = 'https://buff.163.com/api/market/goods/bill_order?game=csgo&goods_id=' + goodsid
    43                 tradeurl = 'https://buff.163.com/api/market/goods/sell_order?game=csgo&goods_id=' + goodsid + '&page_num=1&sort_by=default&mode=&allow_tradable_cooldown=1'
    44                 flag =0
    45                 point = requests.get(hisurl, headers=header, timeout=5)
    46                 turn = point.content.decode(encoding='gbk', errors='ignore')
    47                 res = json.loads(turn)
    48                 try:
    49                     if str(res['data']['items'][0]['buyer_pay_time']) == "1566403200" and str(res['data']['items'][1]['buyer_pay_time']) == "1566403200":
    50                         print(itemname+" "+str(content['价格']))
    51                         flag = 1
    52                 except:
    53                     print("https://buff.163.com/market/goods?goods_id="+goodsid+"&from=market#tab=history")
    54                 if flag==1:
    55                     z.write(tradeurl + '
    ')
    56                     z.write(hisurl + '
    ')
    57                     z.write(itemname+'
    ')
    58 def getigxedatagunsurl():
    59     global itemsdict
    60     itemsdict ={}
    61     kk = open('buffdataknife2', 'r', encoding='utf-8')  ##################
    62     igxe = open("igxedataknife2" , 'w' , encoding='utf-8')  ##################
    63     count = (int)(1617/3)                                            ##################
    64     for i in range(0, count):
    65         tradeurl = kk.readline()
    66         hisurl = kk.readline()
    67         itemname = kk.readline()
    68         itemsdict[itemname] = 1
    69         print(itemname+"BUFF")
    70     url = "https://www.igxe.cn/csgo/730?ctg_name=%E5%8C%95%E9%A6%96&is_buying=0&is_stattrak%5B%5D=0&is_stattrak%5B%5D=0&sort=3&ctg_id=5&type_id=0&page_no=1&page_size=2000&rarity_id=0&exterior_id=0&quality_id=0&capsule_id=0&_t=1566576849724"   ##################
    71     driver = webdriver.Chrome()
    72     driver.maximize_window()
    73     driver.set_page_load_timeout(20)
    74     try:
    75         driver.get(url)
    76     except:
    77         pass
    78     for i in range(1,2000):
    79         try:
    80             namexpath = driver.find_element_by_xpath('//*[@id="center"]/div/div[3]/div/div[2]/a['+str(i)+']/div[3]')
    81             urlxpath = driver.find_element_by_xpath('//*[@id="center"]/div/div[3]/div/div[2]/a['+str(i)+']')
    82             url = urlxpath.get_attribute('href')
    83             goodsid = url.replace("https://www.igxe.cn/product/730/","")
    84             name = namexpath.text +"
    "
    85             name = name.replace(" ","")
    86             if name in itemsdict.keys():
    87                 print(name)
    88                 igxe.write("https://www.igxe.cn/product/get_product_sales_history/730/"+goodsid+"
    ")
    89                 igxe.write("https://www.igxe.cn/product/trade/730/"+goodsid+"
    ")
    90         except Exception as e:
    91             print(e)
    92             break
    93 if __name__ =='__main__':
    94     getigxedatagunsurl()
    View Code

    主程序源码

       1 # coding:utf-8
       2 from multiprocessing import freeze_support
       3 import requests
       4 import json
       5 from datetime import datetime
       6 import re
       7 import threading
       8 import time
       9 import os
      10 import urllib3
      11 import win32com.client
      12 from appium import webdriver as appwebdriver
      13 import itchat
      14 from selenium import webdriver
      15 from selenium.webdriver import ActionChains
      16 from selenium.webdriver.common.keys import Keys
      17 from itchat.content import *
      18 import smtplib
      19 from email.mime.text import MIMEText
      20 '''
      21 购物车检测是否有1w
      22 '''
      23 '''
      24 cd D:pythonuff爬虫uff爬虫
      25 D:
      26 pyinstaller -p D:pythonuff爬虫uff爬虫venvLibsite-packages autobuy_xiaomi8se.py
      27 '''
      28 def checktimeout():
      29     global check
      30     try:
      31         appdriver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.alipay.android.phone.safepaybase:id/key_num_dymic")')
      32         check = 1
      33     except Exception as e:
      34         try:
      35             appdriver.tap([(179, 2160), (179, 2160)], 1)
      36         except:
      37             pass
      38         print(e)
      39 def aliypay():
      40     global runtime
      41     global append
      42     global check
      43     global appdriver
      44     while 1 :
      45         try:
      46             if runtime == 150:
      47                 break
      48             runtime +=1
      49             if appdriver.find_element_by_id('cn.igxe:id/confirm_payment_actual_price_tv').text==buyprice:
      50                 appdriver.tap([(949, 1104), (949, 1104)], 100)
      51                 appdriver.tap([(949, 1104), (949, 1104)], 100)
      52                 appdriver.tap([(567, 2200), (567, 2200)], 100)
      53                 appdriver.tap([(567, 2200), (567, 2200)], 100)
      54                 break
      55             else:
      56                 itchat.send_msg("物品价格与加入购物车时不符",toUserName=itcaht_user_name)
      57                 append = datetime.now()
      58                 runtime = 150
      59                 appdriver.back()
      60                 appdriver.back()
      61                 appdriver.back()
      62                 return
      63         except Exception as e:
      64             print(e)
      65     check = 0
      66     time.sleep(2)
      67     #appdriver.implicitly_wait(0.2)
      68     while 1:
      69         try:
      70             if runtime == 150:
      71                 break
      72             runtime+=1
      73             appdriver.tap([(179, 2160), (179, 2160)], 1)
      74             t = threading.Thread(target=checktimeout)
      75             t.setDaemon(True)
      76             t.start()
      77             t.join(timeout=0.5)
      78             if check==0:
      79                 adb2 = "adb shell input tap 179 2160"
      80                 os.system(adb2)
      81                 continue
      82             appdriver.tap([(875, 2060), (875, 2060)], 1)
      83             appdriver.tap([(574, 2060), (574, 2060)], 1)
      84             appdriver.tap([(875, 2060), (875, 2060)], 1)
      85             appdriver.tap([(574, 2060), (574, 2060)], 1)
      86             appdriver.tap([(875, 2060), (875, 2060)], 1)
      87             appdriver.tap([(574, 2060), (574, 2060)], 1)
      88             break
      89         except Exception as e:
      90             print(e)
      91             try:
      92                 appdriver.tap([(179, 2160), (179, 2160)], 1)
      93             except:
      94                 pass
      95 def wechatpay():
      96     global runtime
      97     global append
      98     while 1 :
      99         try:
     100             if runtime == 150:
     101                 break
     102             runtime +=1
     103             appdriver.find_element_by_name('微信支付').click()
     104             appdriver.tap([(950, 1800), (950, 1800)], 100)
     105             appdriver.tap([(950, 1800), (950, 1800)], 100)
     106             break
     107         except:
     108             pass
     109     while 1 :
     110         try:
     111             if runtime == 150:
     112                 break
     113             runtime +=1
     114             if appdriver.find_element_by_id("com.tencent.mm:id/fdj").text==buyprice:
     115                 appdriver.tap([(546, 725), (546, 725)], 100)
     116                 appdriver.tap([(546, 725), (546, 725)], 100)
     117                 time.sleep(0.3)
     118                 appdriver.tap([(950, 1700), (950, 1700)], 1)
     119                 appdriver.tap([(550, 1700), (550, 1700)], 1)
     120                 appdriver.tap([(950, 1700), (950, 1700)], 1)
     121                 appdriver.tap([(550, 1700), (550, 1700)], 1)
     122                 appdriver.tap([(950, 1700), (950, 1700)], 1)
     123                 appdriver.tap([(550, 1700), (550, 1700)], 1)
     124                 append = datetime.now()
     125             else:
     126                 append = datetime.now()
     127                 itchat.send_msg("商品价格与一开始不符",toUserName=itcaht_user_name)
     128                 findmainweb()
     129             break
     130         except:
     131             pass
     132     while 1:
     133         try:
     134             if runtime == 150:
     135                 break
     136             runtime +=1
     137             appdriver.find_element_by_name('返回商家').click()
     138             break
     139         except:
     140             pass
     141 def calc_count():
     142     strday = "RUNLOG-" + time.strftime('%Y-%m-%d', time.localtime(time.time())) + ".txt"
     143     with open(strday, "r", encoding='utf-8') as log:
     144         temp = log.readlines()
     145         pattern = re.compile('([0-9]*?)')
     146         result1 = pattern.findall(str(temp))
     147         #print(result1)
     148         i = len(result1)
     149         if i>0:
     150             res = result1[i-1].replace("(","").replace(")","")
     151             res = int(res)
     152             print(res)
     153             return res
     154         else:
     155             return 0
     156 def judgetime():
     157     global itemcount
     158     strtime = time.strftime('%H:%M:%S', time.localtime(time.time()))
     159     pattern = re.compile('00:00:')
     160     result1 = pattern.findall(str(strtime))
     161     if len(result1)==1:
     162         time.sleep(60)
     163         itemcount = 0
     164 def findmainweb():
     165     global appdriver
     166     try:
     167         appdriver.find_element_by_id("cn.igxe:id/personalImageView")
     168         return
     169     except:
     170         pass
     171     time = 0
     172     while 1:
     173         try:
     174             time +=1
     175             if time == 100:
     176                 try:
     177                     appdriver.quit()
     178                     time.sleep(2)
     179                 except:
     180                     pass
     181                 appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
     182                 time.sleep(7)
     183             appdriver.back()
     184             try:
     185                 appdriver.find_element_by_id('com.alipay.android.app:id/flybird_dialog_double_right_btn').click() #啥玩意
     186             except:
     187                 pass
     188             appdriver.find_element_by_id("cn.igxe:id/personalImageView")
     189             break
     190         except:
     191             pass
     192 def updatealiypay():
     193     global appdriver
     194     trytime = 0
     195     findmainweb()
     196     try:
     197         appdriver.find_element_by_name("跳过此版本").click()
     198     except:
     199         pass
     200     while 1:
     201         try:
     202             if trytime == 100:
     203                 break
     204             trytime +=1
     205             appdriver.find_element_by_id('cn.igxe:id/mallTextView')
     206             appdriver.tap([(136, 2150), (136, 2150)], 1)
     207             appdriver.tap([(136, 2150), (136, 2150)], 1)
     208             break
     209         except Exception as e:
     210             pass
     211     while 1:
     212         try:
     213             if trytime == 100:
     214                 break
     215             trytime += 1
     216             appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/goods_list_recycler"]/android.view.ViewGroup[1]').click()
     217             break
     218         except Exception as e:
     219             pass
     220     while 1:
     221         try:
     222             if trytime == 100:
     223                 break
     224             trytime += 1
     225             appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/sale_recyclerView"]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.TextView[3]').click()
     226             break
     227         except Exception as e:
     228             pass
     229     while 1:
     230         try:
     231             if trytime == 100:
     232                 break
     233             trytime += 1
     234             appdriver.find_element_by_name("支付宝支付").click()
     235             break
     236         except:
     237             pass
     238     try:
     239         appdriver.find_element_by_id("cn.igxe:id/confirm_payment_commit_btn").click()
     240     except:
     241         pass
     242     if trytime == 100:
     243         try:
     244             appdriver.quit()
     245             time.sleep(2)
     246             appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
     247         except:
     248             pass
     249     time.sleep(5)
     250     appdriver.back()
     251     appdriver.back()
     252     appdriver.back()
     253     findmainweb()
     254     cleancart()
     255 def cleancart():
     256     appdriver.tap([(971, 2150), (971, 2150)], 1)
     257     appdriver.tap([(971, 2150), (971, 2150)], 1)
     258     appdriver.tap([(779, 2150), (779, 2150)], 1)
     259     appdriver.tap([(779, 2150), (779, 2150)], 1)
     260     runtime = 0
     261     while 1:
     262         try:
     263             if runtime == 50:
     264                 break
     265             runtime += 1
     266             appdriver.find_element_by_name('管理').click()  # 待改
     267             break
     268         except:
     269             pass
     270     while 1:
     271         try:
     272             if runtime == 50:
     273                 break
     274             runtime += 1
     275             appdriver.find_element_by_name('全选').click()  # 待改
     276             break
     277         except:
     278             pass
     279     while 1:
     280         try:
     281             if runtime == 50:
     282                 break
     283             runtime += 1
     284             appdriver.find_element_by_id("cn.igxe:id/item_shopping_cart_commit_tv").click()
     285             break
     286         except:
     287             pass
     288 def get_screen_and_send_web(pre):
     289     screenshot = time.ctime().replace(":", "-")
     290     driver.get_screenshot_as_file("C:\Users\86131\Desktop\bugscreen\" + pre+screenshot + ".png")
     291     itchat.send_image(u"C:\Users\86131\Desktop\bugscreen/" + pre + screenshot + ".png",
     292                       toUserName=itcaht_user_name)
     293 def log(printsrt):
     294     strtime = time.strftime('%H:%M:%S', time.localtime(time.time()))
     295     strday = "RUNLOG-"+time.strftime('%Y-%m-%d', time.localtime(time.time()))+".txt"
     296     print(strtime + "  " + str(printsrt))
     297     with open (strday,"a",encoding='utf-8') as log:
     298         log.write(strtime+"  "+str(printsrt)+"
    ")
     299 def timeprint(printsrt):
     300     strtime = time.strftime('%H:%M:%S', time.localtime(time.time()))
     301     print(strtime + "  " + str(printsrt))
     302 def after_logout():
     303     log("退出后调用")
     304     sendmsg_2()
     305 def checkbuy_info():
     306     global  appdriver
     307     global buyprice
     308     runtime_1 = 0
     309     try:
     310         if appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/recyclerView"]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.TextView[3]').text=="待买家发起报价":
     311             appdriver.tap([(562, 695), (562, 695)], 1)
     312             time.sleep(2)
     313             float1 = float(appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/unit_price_tv"]').text)
     314             if float1==float(buyprice):
     315                 try:
     316                     itchat.send_msg("价格正确,正在发送报价", toUserName=itcaht_user_name)
     317                 except:
     318                     pass
     319             else:
     320                 try:
     321                     itchat.send_msg("价格不匹配,终止交易",toUserName=itcaht_user_name)
     322                 except:
     323                     pass
     324                 return
     325             while 1:
     326                 try:
     327                     if runtime_1 == 50:
     328                         itchat.send_msg("发送报价失败",toUserName=itcaht_user_name)
     329                         break
     330                     runtime_1 += 1
     331                     appdriver.find_element_by_name('发送报价').click()
     332                     time.sleep(2)
     333                     appdriver.find_element_by_name('我已开启').click()
     334                     break
     335                 except:
     336                     pass
     337             time.sleep(6)
     338             appdriver.back()
     339             time.sleep(1)
     340             appdriver.back()
     341             time.sleep(1)
     342             get_screen_and_send("BUYINFO-")
     343             if appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/recyclerView"]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.TextView[3]').text == "待买家发起报价":
     344                 itchat.send_msg("发送报价失败",toUserName=itcaht_user_name)
     345             else:
     346                 itchat.send_msg("发送报价成功",toUserName=itcaht_user_name)
     347     except:
     348         itchat.send_msg("出现未知错误", toUserName=itcaht_user_name)
     349         get_screen_and_send("ERROR-")
     350         try:
     351             appdriver.quit()
     352         except:
     353             pass
     354         time.sleep(1)
     355         appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
     356         time.sleep(8)
     357 def app_autobuy():
     358     global buyprice
     359     global appdriver
     360     global buyinfo
     361     global endtime
     362     global nowtime
     363     global runtime
     364     global append
     365     runtime = 0
     366     appnow = datetime.now()
     367     appdriver.tap([(958, 2200), (958, 2200)], 100)
     368     appdriver.tap([(958, 2200), (958, 2200)], 100)
     369     appdriver.tap([(751, 2200), (751, 2200)], 100)
     370     appdriver.tap([(751, 2200), (751, 2200)], 100)
     371     time.sleep(0.7)
     372     appdriver.tap([(125, 2039), (125, 2039)], 100)
     373     appdriver.tap([(936, 2050), (936, 2050)], 100)
     374     appdriver.tap([(936, 2050), (936, 2050)], 100)
     375     aliypay()
     376     append = datetime.now()
     377     log("购买耗时: " + str(append - appnow+endtime-nowtime) + '
    ' + "runtime = " + str(runtime))
     378     itchat.send_msg("火狐耗时:"+str(endtime-nowtime)+"
    "+"APP耗时:"+str(append - appnow)+"
    "+"购买总耗时: " + str(append - appnow+endtime-nowtime) + '
    ' + "JS执行次数 = " + str(runtime)+"/150", toUserName=itcaht_user_name)
     379     get_screen_and_send("PAY-")
     380     time.sleep(2)
     381     try:
     382         appdriver.find_element_by_name('跳过').click()
     383     except:
     384         pass
     385     try:
     386         appdriver.find_element_by_name('我知道了').click()
     387     except:
     388         pass
     389     try:
     390         appdriver.find_element_by_name('完成').click()
     391     except:
     392         pass
     393 
     394     while 1:
     395         try:
     396             if runtime == 150:
     397                 get_screen_and_send("BUG-")
     398                 appdriver.back()
     399                 appdriver.back()
     400                 appdriver.back()
     401                 appdriver.quit()
     402                 time.sleep(2)
     403                 appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
     404                 break
     405             runtime +=1
     406             break
     407         except:
     408             pass
     409     time.sleep(8)
     410     findmainweb()
     411     try:
     412         appdriver.find_element_by_name('跳过此版本').click()
     413     except:
     414         pass
     415     temperror = 0
     416     while 1:
     417         try:
     418             if temperror ==50:
     419                 get_screen_and_send("BUG-")
     420                 appdriver.back()
     421                 appdriver.back()
     422                 appdriver.back()
     423                 appdriver.quit()
     424                 time.sleep(2)
     425                 appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
     426                 time.sleep(5)
     427                 appdriver.tap([(958, 2056), (958, 2056)], 100)
     428                 time.sleep(1)
     429                 appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/personalLayout"]').click()
     430                 break
     431             temperror+=1
     432             appdriver.tap([(971, 2150), (971, 2150)], 1)
     433             appdriver.tap([(971, 2150), (971, 2150)], 1)
     434             time.sleep(2)
     435             appdriver.tap([(182, 1091), (182, 1091)], 1)
     436             appdriver.tap([(182, 1091), (182, 1091)], 1)
     437             break
     438         except:
     439             pass
     440     time.sleep(3)
     441     get_screen_and_send("ORDERSTATUS-")
     442     checkbuy_info()
     443     appdriver.back()
     444     if runtime == 150:
     445         itchat.send_msg("出现错误,正在尝试删除购物车货物", toUserName=itcaht_user_name)
     446         time.sleep(2)
     447         runtime = 0
     448         findmainweb()
     449         appdriver.tap([(971, 2150), (971, 2150)], 1)
     450         appdriver.tap([(971, 2150), (971, 2150)], 1)
     451         appdriver.tap([(779, 2150), (779, 2150)], 1)
     452         appdriver.tap([(779, 2150), (779, 2150)], 1)
     453         while 1:
     454             try:
     455                 if runtime == 50:
     456                     break
     457                 runtime += 1
     458                 appdriver.find_element_by_name('管理').click() #待改
     459                 break
     460             except:
     461                 pass
     462         get_screen_and_send("PRICE-")
     463         while 1:
     464             try:
     465                 if runtime == 50:
     466                     break
     467                 runtime += 1
     468                 appdriver.find_element_by_name('全选').click() #待改
     469                 break
     470             except:
     471                 pass
     472         while 1:
     473             try:
     474                 if runtime == 50:
     475                     break
     476                 runtime += 1
     477                 appdriver.find_element_by_id("cn.igxe:id/item_shopping_cart_commit_tv").click()
     478                 break
     479             except:
     480                 pass
     481         judgedel = 0
     482         try:
     483             appdriver.find_element_by_name('管理') #待改
     484             judgedel = 1
     485         except:
     486             pass
     487         if (judgedel == 0):
     488             log("删除成功")
     489             itchat.send_msg("购物车货物删除成功",toUserName=itcaht_user_name)
     490             get_screen_and_send("PURCHASE-")
     491         else:
     492             log("仍然活着")
     493             itchat.send_msg("购物车货物删除失败", toUserName=itcaht_user_name)
     494             get_screen_and_send("PURCHASE-")
     495     buyinfo = 0
     496 def get_screen_and_send(pre):
     497     try:
     498         screenshot = time.ctime().replace(":", "-")
     499         appdriver.get_screenshot_as_file(
     500             u"C:\Users\86131\Desktop\bugscreen\" + pre+screenshot + ".png")
     501         itchat.send_image(u"C:\Users\86131\Desktop\bugscreen/" +pre+ screenshot + ".png",
     502                           toUserName=itcaht_user_name)
     503     except:
     504         sendmsg_2()
     505 def judge_app_online_login_and_app_front():
     506     global appdriver
     507     global appcookies
     508     judgelogin = 0
     509     try:
     510         appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/shoppingCartLayout"]').click()
     511     except:
     512         #itchat.send_msg("IGXEAPP不在前台 , 正在尝试重启",toUserName=itcaht_user_name)
     513         try:
     514             appdriver.quit()
     515         except:
     516             pass
     517         time.sleep(1)
     518         appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
     519         time.sleep(5)
     520         #get_screen_and_send("STATE-")
     521     time.sleep(2)
     522     try:
     523         if appdriver.find_element_by_id("cn.igxe:id/sign_in_button").text == "登录":
     524             judgelogin = 1
     525             itchat.send_msg("igxe未登录,正在尝试登录", toUserName=itcaht_user_name)
     526             appdriver.find_element_by_id("cn.igxe:id/account").clear()
     527             appdriver.find_element_by_id("cn.igxe:id/account").send_keys("******")
     528             appdriver.find_element_by_id("cn.igxe:id/password").send_keys("xxxxxxxxxxx")
     529             appdriver.hide_keyboard()
     530             time.sleep(0.5)
     531             appdriver.find_element_by_id("cn.igxe:id/sign_in_button").click()
     532     except:
     533         log("igxe已登录")
     534     time.sleep(1)
     535     try:
     536         appdriver.find_element_by_xpath('//*[@resource-id="cn.igxe:id/personalLayout"]').click()
     537     except:
     538         pass
     539     time.sleep(1)
     540     try:
     541         if judgelogin == 1:
     542             if appdriver.find_element_by_id("cn.igxe:id/userName").text=="MB秒发123":
     543                 itchat.send_msg("登陆成功", toUserName=itcaht_user_name)
     544             else:
     545                 itchat.send_msg("登陆失败",toUserName=itcaht_user_name)
     546                 get_screen_and_send("LOGIN-")
     547     except:
     548         pass
     549 def keep_app_open():
     550     global appdriver
     551     try:
     552         appdriver.tap([(-1, -1), (-1, -1)], 0)
     553     except Exception as e:
     554         pass
     555 def logintoigxe():
     556     keep_app_open()
     557     global driver
     558     driver.set_page_load_timeout(3)
     559     try:
     560         driver.get('https://www.igxe.cn/product/730/555335')
     561     except:
     562         pass
     563     time.sleep(2)
     564     try:
     565         buy1 = driver.find_element_by_xpath(
     566             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a[1]')
     567     except:
     568         pass
     569     try:
     570         buy2 = driver.find_element_by_xpath(
     571             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a[2]')
     572     except:
     573         pass
     574     try:
     575         buy3 = driver.find_element_by_xpath(
     576             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a')
     577     except:
     578         pass
     579     try:
     580         if buy1.text == '加入购物车':
     581             buy = buy1
     582     except:
     583         pass
     584     try:
     585         if buy2.text == '加入购物车':
     586             buy = buy2
     587     except:
     588         pass
     589     try:
     590         if buy3.text == '加入购物车':
     591             buy = buy3
     592     except:
     593         pass
     594     ActionChains(driver).click(buy).perform()
     595     time.sleep(3)
     596     click = driver.find_element_by_xpath('/html/body/div[4]/div[1]/div/div[1]/form/ul/li[2]')
     597     ActionChains(driver).click(click).perform()
     598     time.sleep(1)
     599     key = driver.find_element_by_xpath('//*[@id="password"]')
     600     key.send_keys('xxxxxxxxxxx')
     601     username = driver.find_element_by_xpath('//*[@id="username"]')
     602     username.send_keys('******321')
     603     click = driver.find_element_by_xpath('//*[@id="login-btn"]')
     604     ActionChains(driver).click(click).perform()
     605     while 1:
     606         try:
     607             tses = driver.find_element_by_xpath(
     608                 '/html/body/div[3]/div[1]/div[1]/div/div/div[2]/ul/li[7]/a[2]')
     609             if(tses.text=='MB秒发123'):
     610                 break
     611         except:
     612             pass
     613     keep_app_open()
     614 def sendmsg(zhenshi,strtime,output,chajia,earnrate,jinglirun):
     615     host = 'smtp.163.com'
     616     sender = '******321@163.com'
     617     pwd = 'qq******123'
     618     receiver = '652235835@qq.com'
     619     body = zhenshi+strtime+'
    '+'价格:' + output+'
    ' + 'buff差价:' + "%.2f" % float(chajia)+'
    ' + '利率:' + "%.2f" % float(earnrate) + '%'+'
    '+'净利润:'+"%.2f" % float(jinglirun) + '
    '
     620     msg = MIMEText(body)
     621     msg['subject'] = '价格:' + output+'
    ' '净利润:'+"%.2f" % float(jinglirun) + '
    ' + zhenshi
     622     msg['from'] = sender
     623     msg['to'] = receiver
     624     s = smtplib.SMTP_SSL(host)
     625     s.login(sender, pwd)
     626     s.sendmail(sender, receiver, msg.as_string())
     627 def sendmsg_2():
     628     host = 'smtp.163.com'
     629     sender = '******321@163.com'
     630     pwd = 'qq******123'
     631     receiver = '******@qq.com'
     632     body = "wdnmd"
     633     msg = MIMEText(body)
     634     msg['subject'] = "掉线了都"
     635     msg['from'] = sender
     636     msg['to'] = receiver
     637     s = smtplib.SMTP_SSL(host)
     638     s.login(sender, pwd)
     639     s.sendmail(sender, receiver, msg.as_string())
     640 def getcookies():
     641     keep_app_open()
     642     global cookies
     643     log('get new cookie')
     644     getcookiesdriver = webdriver.Firefox()
     645     getcookiesdriver.maximize_window()
     646     getcookiesdriver.set_page_load_timeout(3)
     647     time.sleep(1)
     648     try:
     649         getcookiesdriver.get('https://www.igxe.cn/product/730/555335')
     650     except:
     651         pass
     652     time.sleep(2)
     653     try:
     654         buy1 = getcookiesdriver.find_element_by_xpath(
     655             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a[1]')
     656     except:
     657         pass
     658     try:
     659         buy2 = getcookiesdriver.find_element_by_xpath(
     660             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a[2]')
     661     except:
     662         pass
     663     try:
     664         buy3 = getcookiesdriver.find_element_by_xpath(
     665             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a')
     666     except:
     667         pass
     668 
     669     try:
     670         if buy1.text == '加入购物车':
     671             buy = buy1
     672     except:
     673         pass
     674     try:
     675         if buy2.text == '加入购物车':
     676             buy = buy2
     677     except:
     678         pass
     679     try:
     680         if buy3.text == '加入购物车':
     681             buy = buy3
     682     except:
     683         pass
     684     ActionChains(getcookiesdriver).click(buy).perform()
     685     time.sleep(3)
     686     click = getcookiesdriver.find_element_by_xpath('/html/body/div[4]/div[1]/div/div[1]/form/ul/li[2]')
     687     ActionChains(getcookiesdriver).click(click).perform()
     688     time.sleep(1)
     689     key = getcookiesdriver.find_element_by_xpath('//*[@id="password"]')
     690     key.send_keys('xxxxxxxxxxx')
     691     username = getcookiesdriver.find_element_by_xpath('//*[@id="username"]')
     692     username.send_keys('18580890781')
     693     click = getcookiesdriver.find_element_by_xpath('//*[@id="login-btn"]')
     694     ActionChains(getcookiesdriver).click(click).perform()
     695     while 1:
     696         try:
     697             tses = getcookiesdriver.find_element_by_xpath(
     698                 '/html/body/div[3]/div[1]/div[1]/div/div/div[2]/ul/li[7]/a[2]')
     699             if(tses.text=='Igxe85185222'):
     700                 break
     701         except Exception as e:
     702             pass
     703     cookies = getcookiesdriver.get_cookies()
     704     time.sleep(1)
     705     getcookiesdriver.quit()
     706     keep_app_open()
     707 def judgecookie():
     708     keep_app_open()
     709     global cookies1
     710     headers = {
     711         'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/71.0.3578.98 Safari/537.36',
     712     }
     713     url = 'https://www.igxe.cn/product/730/555335'
     714     for cookie in cookies:
     715         cookies1[cookie['name']] = cookie['value']
     716     point = requests.get(url, cookies=cookies1, headers=headers,timeout = 10)
     717     pattern = re.compile('.*?85185222.*?')
     718     result1 = pattern.findall(point.text)
     719     if result1!=[]:
     720         log("spider with cookie online")
     721     else:
     722         log("spider offline,try to get new cookie")
     723         getcookies()
     724     keep_app_open()
     725 def getbuyurl(tradeurl,hisurl,itemname):
     726     try:
     727         keep_app_open()
     728         global itemsdict
     729         global bufflowprice
     730         global k
     731         global first_url_count
     732         global getcount
     733         global count
     734         global nofound
     735         point = requests.get(hisurl,headers=header,timeout = 5,cookies=cookies1)
     736         turn = point.content.decode(encoding='gbk',errors='ignore')
     737         res = json.loads(turn)
     738         content_list = []
     739         for i in res['data']['items']:
     740             content = {}
     741             content['价格']=i['price']
     742             content_list.append(float(content['价格']))
     743         content_list.sort()
     744         if len(content_list) >= 2:
     745             pingjun = content_list[0] + content_list[1] + content_list[2]
     746             pingjun = pingjun/3
     747             hisprice = content_list[1]
     748         if len(content_list) == 1:
     749             hisprice = content_list[0]
     750         if len(content_list) == 0:
     751             hisprice = 0
     752         point = requests.get(tradeurl, headers=header,timeout = 5,cookies=cookies1)
     753         turn = point.content.decode(encoding='gbk', errors='ignore')
     754         res = json.loads(turn)
     755         sum=1
     756         global url
     757         url = tradeurl
     758         url = url.replace('https://buff.163.com/api/market/goods/sell_order?game=csgo&goods_id=', '')
     759         url = url.replace('&page_num=1&sort_by=default&mode=&allow_tradable_cooldown=1', '')
     760         url = url.replace('
    ', '')
     761         url = 'https://buff.163.com/market/goods?goods_id=' + url + '&from=market#tab=selling' + '
    '
     762         for i in res['data']['items']:
     763             content = {}
     764             content['价格']=i['price']
     765             if sum == 1:
     766                 userid = i['user_id']
     767                 price1 = float(content['价格'])
     768                 itemsdict[itemname] = price1
     769                 itemsdict['price'+itemname]=pingjun
     770             if sum == 2:
     771                 price2 = float(content['价格'])
     772                 chajia = price2 - price1
     773                 earnrate = chajia / itemsdict['price'+itemname]
     774                 earnrate *= 100
     775             sum+=1
     776             if sum == 3:
     777                 if hisprice > 0:
     778                         if earnrate > 7:
     779                             if price1*1.03<pingjun:
     780                                 if price1*1.05<price2:
     781                                     getcount +=1
     782                                     with open('buyforself.txt','a',encoding='utf-8') as z:
     783                                         log(url.replace('
    ',''))
     784                                         log('价格:'+ str(price1)+'     差价:'+str(chajia)+'    利率:'+str(earnrate)+'%')
     785                                         #itchat.send_msg(itemname,toUserName=itcaht_user_name_sam)
     786                                         #itchat.send_msg(url.replace('
    ',''), toUserName=itcaht_user_name_sam)
     787                                         #itchat.send_msg('价格:'+ str(price1)+'     差价:'+str(chajia)+'    利率:'+str(earnrate)+'%',toUserName=itcaht_user_name_sam)
     788                                         z.write(url)
     789                                         z.write('价格:'+ str(price1)+'     差价:'+str(chajia)+'    利率:'+str(earnrate)+'%'+'
    ')
     790     except Exception as e:
     791         pass
     792 buffcount=0
     793 def getbuyurl_hc(tradeurl,hisurl,itemname):
     794     while 1:
     795         try:
     796             global buffcount
     797             global itemsdict
     798             global bufflowprice
     799             global k
     800             global first_url_count
     801             global getcount
     802             global count
     803             global nofound
     804             global buff_judge_exist
     805             keep_app_open()
     806             if (tradeurl in buff_judge_exist.keys()):
     807                 break
     808             point = requests.get(hisurl,headers=header,timeout = 5,cookies=cookies1)
     809             turn = point.content.decode(encoding='gbk',errors='ignore')
     810             res = json.loads(turn)
     811             content_list = []
     812             for i in res['data']['items']:
     813                 content = {}
     814                 content['价格']=i['price']
     815                 content_list.append(float(content['价格']))
     816             content_list.sort()
     817             if len(content_list) >= 2:
     818                 pingjun = content_list[0] + content_list[1] + content_list[2]
     819                 pingjun = pingjun/3
     820                 hisprice = content_list[1]
     821             if len(content_list) == 1:
     822                 hisprice = content_list[0]
     823             if len(content_list) == 0:
     824                 hisprice = 0
     825             point = requests.get(tradeurl, headers=header,timeout = 5,cookies=cookies1)
     826             turn = point.content.decode(encoding='gbk', errors='ignore')
     827             res = json.loads(turn)
     828             sum=1
     829             global url
     830             url = tradeurl
     831             url = url.replace('https://buff.163.com/api/market/goods/sell_order?game=csgo&goods_id=', '')
     832             url = url.replace('&page_num=1&sort_by=default&mode=&allow_tradable_cooldown=1', '')
     833             url = url.replace('
    ', '')
     834             url = 'https://buff.163.com/market/goods?goods_id=' + url + '&from=market#tab=selling' + '
    '
     835             for i in res['data']['items']:
     836                 content = {}
     837                 content['价格']=i['price']
     838                 if sum == 1:
     839                     userid = i['user_id']
     840                     price1 = float(content['价格'])
     841                     itemsdict[itemname] = price1
     842                     itemsdict['price'+itemname]=pingjun
     843                 if sum == 2:
     844                     price2 = float(content['价格'])
     845                     chajia = price2 - price1
     846                     earnrate = chajia / itemsdict['price'+itemname]
     847                     earnrate *= 100
     848                 sum+=1
     849                 if sum == 3:
     850                     if hisprice > 0:
     851                             if earnrate > 7:
     852                                 if price1*1.03<pingjun:
     853                                     if price1*1.05<price2:
     854                                         getcount +=1
     855                                         with open('buyforself.txt','a',encoding='utf-8') as z:
     856                                             log(url.replace('
    ',''))
     857                                             log('价格:'+ str(price1)+'     差价:'+str(chajia)+'    利率:'+str(earnrate)+'%')
     858                                             #itchat.send_msg(itemname,toUserName=itcaht_user_name_sam)
     859                                             #itchat.send_msg(url.replace('
    ',''), toUserName=itcaht_user_name_sam)
     860                                             #itchat.send_msg('价格:'+ str(price1)+'     差价:'+str(chajia)+'    利率:'+str(earnrate)+'%',toUserName=itcaht_user_name_sam)
     861                                             z.write(url)
     862                                             z.write('价格:'+ str(price1)+'     差价:'+str(chajia)+'    利率:'+str(earnrate)+'%'+'
    ')
     863             buff_judge_exist[tradeurl]=1
     864             buffcount +=1
     865             print("
    "+str(buffcount)+'/840',end='')
     866             break
     867         except Exception as e:
     868             pass
     869 def igxegetdict(fpoint):
     870     try:
     871         state = {
     872             "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/39.0.2171.71 Safari/537.36"}
     873         sellhistoryurl = fpoint.readline()
     874         tradeurl = fpoint.readline()
     875         point = requests.get(sellhistoryurl, headers=state, timeout=5,cookies=cookies1)
     876         turn = point.content.decode(encoding='gbk', errors='ignore')
     877         js = json.loads(turn)
     878         temp = js['data']
     879         content_list = []
     880         for i in temp:
     881             content = {}
     882             content['价格'] = i['unit_price']
     883             itemname = i['name']
     884             content_list.append(float(content['价格']))
     885         content_list.sort()
     886         zhenshi = itemname.replace(' ', '') + '
    '
     887         if len(content_list) >= 2:
     888             hisprice = content_list[1]
     889             pingjun = content_list[0] + content_list[1] + content_list[2]
     890             pingjun = pingjun / 3
     891             itemsdict['pingjun' + zhenshi] = pingjun
     892             itemsdict['hisprice' + zhenshi] = hisprice
     893         #      log('pingjun'+zhenshi+"已录入, 值为"+str(itemsdict['pingjun'+zhenshi]))
     894         #      log('hisprice'+zhenshi+"已录入, 值为"+str(itemsdict['hisprice'+zhenshi]))
     895         if len(content_list) == 1:
     896             hisprice = content_list[0]
     897             itemsdict['pingjun' + zhenshi] = 0
     898             itemsdict['hisprice' + zhenshi] = hisprice
     899         if len(content_list) == 0:
     900             hisprice = 0
     901             itemsdict['pingjun' + zhenshi] = 0
     902             itemsdict['hisprice' + zhenshi] = hisprice
     903         first_url_count += 1
     904     except :
     905         pass
     906 def igxegetbuyurl(tradeurl):
     907     try:
     908         global itemsdict
     909         global getcount
     910         global first_url_count
     911         global count
     912         global nofound
     913         global driver
     914         global buyprice
     915         global fbuyprice
     916         global buyinfo
     917         global driver
     918         global nowtime
     919         global endtime
     920         global nowprice
     921         global itemcount
     922         if buyinfo ==0:
     923             nowtime = datetime.now()
     924             try:
     925                 driver.get(tradeurl.replace("/trade", ""))
     926             except:
     927                 pass
     928             itemcount +=1
     929             strtime = time.strftime('%H:%M:%S', time.localtime(time.time()))
     930             headers = {
     931                 "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/39.0.2171.71 Safari/537.36"}
     932             ret = requests.get(tradeurl, headers=headers,timeout = 3,cookies=cookies1)
     933             r = ret.content.decode(encoding='gbk',errors='ignore')
     934             res = json.loads(r)
     935             content_list = []
     936             sum=1
     937             price1=0.0
     938             price2=0.0
     939             for i in res['d_list']:
     940                 content = {}
     941                 content['价格'] = i['unit_price']
     942                 content['名字'] = i['name']
     943                 content['steamuid']=i['steam_uid']
     944                 content_list.append(content)
     945                 if sum == 1:
     946                     itemname = i['name']
     947                     steamuid = i['steam_uid']
     948                     price1 = float(content['价格'])
     949                 if sum == 2:
     950                     price2 = float(content['价格'])
     951                 sum+=1
     952                 if sum == 3:
     953                     zhenshi = itemname.replace(' ','')+'
    '
     954                     if not (zhenshi in itemsdict.keys()):
     955                         log(itemname+"-------------查无字典")
     956                         break
     957                     chajia = itemsdict[zhenshi] - price1
     958                     log("("+str(itemcount)+")  "+itemname + "  " + "buff价格:" + str(itemsdict[zhenshi]) + "  igxe价格:" + str(price1)+"  差价:"+str(chajia))
     959                     jinglirun = chajia - (itemsdict[zhenshi]*0.035)
     960                     earnrate = chajia / itemsdict[zhenshi]
     961                     earnrate *= 100
     962                     if itemsdict['hisprice' + zhenshi] > 0:
     963                         if price1*1.03<itemsdict['pingjun' + zhenshi]:
     964                             if price1 * 1.03 < price2:
     965                                 if price1 * 1.03 < itemsdict['price' + zhenshi]:
     966                                     if earnrate > 3:
     967                                         #itchat.send_msg(tradeurl.replace("/trade", "")+'价格:' + str(price1) + '  buff差价:' + str(chajia) + '    利率:' + str(earnrate) + '%'+'   净利润:'+str(jinglirun),toUserName=itcaht_user_name_sam)
     968                                         #itchat.send_msg(zhenshi,toUserName=itcaht_user_name_sam)
     969                                         getcount += 1
     970                                         log(tradeurl.replace("/trade", "")+'价格:' + str(price1) + '  buff差价:' + str(chajia) + '    利率:' + str(earnrate) + '%'+'   净利润:'+str(jinglirun))
     971                                     if earnrate >= defearnrate and buyinfo ==1:
     972                                         itchat.send_msg("已经有一个自动购买在运行",toUserName=itcaht_user_name)
     973                                     if earnrate >= defearnrate and buyinfo ==0:
     974                                         buyinfo = 1
     975                                         log("get real msg!")
     976                                         output = "%.2f" % float(price1)
     977                                         itchat.send_msg(zhenshi+strtime+'
    '+'价格:' + str(output)+'
    ' + 'buff差价:' + str(chajia)+'
    ' + '利率:' + str(earnrate) + '%'+'
    '+'净利润:'+str(jinglirun) + '
    ', toUserName=itcaht_user_name)
     978                                         itchat.send_msg("卖家Steam库存:"+'
    '+"https://steamcommunity.com/profiles/"+steamuid+"/inventory/#730", toUserName=itcaht_user_name)
     979                                         if price1<3500 and earnrate > 8.5 :
     980                                             itchat.send_msg("物品符合条件,即将自动购买", toUserName=itcaht_user_name)
     981                                         else:
     982                                             itchat.send_msg("物品不符合自动购买条件,请手动登陆进行购买", toUserName=itcaht_user_name)
     983                                         errortime = 0
     984                                         while 1:
     985                                             try:
     986                                                 errortime += 1
     987                                                 if errortime==1000:
     988                                                     itchat.send_msg("火狐购买页面未能加载",toUserName=itcaht_user_name)
     989                                                     buyinfo = 0
     990                                                     get_screen_and_send_web("WEB-")
     991                                                     break
     992                                                 getpriceelement = driver.find_element_by_xpath(
     993                                                     '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[6]/span')
     994                                                 strprice = "%.2f" % float(price1)
     995                                                 eleprice = str(getpriceelement.text)
     996                                                 eleprice = eleprice.replace("", '')
     997                                                 if eleprice == strprice:
     998                                                     buy = 0
     999                                                     try:
    1000                                                         buy1 = driver.find_element_by_xpath(
    1001                                                             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a[1]')
    1002                                                     except:
    1003                                                         pass
    1004                                                     try:
    1005                                                         buy2 = driver.find_element_by_xpath(
    1006                                                             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a[2]')
    1007                                                     except:
    1008                                                         pass
    1009                                                     try:
    1010                                                         buy3 = driver.find_element_by_xpath(
    1011                                                             '/html/body/div[3]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[7]/a')
    1012                                                     except:
    1013                                                         pass
    1014                                                     try:
    1015                                                         if buy1.text == '加入购物车':
    1016                                                             buy = buy1
    1017                                                     except:
    1018                                                         pass
    1019                                                     try:
    1020                                                         if buy2.text == '加入购物车':
    1021                                                             buy = buy2
    1022                                                     except:
    1023                                                         pass
    1024                                                     try:
    1025                                                         if buy3.text == '加入购物车':
    1026                                                             buy = buy3
    1027                                                     except:
    1028                                                         pass
    1029                                                     try:
    1030                                                         if buy.text != "加入购物车":
    1031                                                             itchat.send_msg("加入购物车失败",toUserName=itcaht_user_name)
    1032                                                     except:
    1033                                                         itchat.send_msg("加入购物车失败", toUserName=itcaht_user_name)
    1034                                                     ActionChains(driver).click(buy).perform()
    1035                                                     time.sleep(0.5)
    1036                                                     fbuyprice = price1
    1037                                                     buyprice = "%.2f" % float(fbuyprice)
    1038                                                     endtime = datetime.now()
    1039                                                     app_autobuy()
    1040                                                 else:
    1041                                                     log("找不到啦")
    1042                                                     buyinfo = 0
    1043                                                 time.sleep(2)
    1044                                                 break
    1045                                             except Exception as e:
    1046                                                 log(e)
    1047                     break
    1048         first_url_count += 1
    1049     except Exception as e:
    1050         pass
    1051 def after_logout():
    1052     log("退出后调用")
    1053     sendmsg_2()
    1054 def check_exsit(process_name):
    1055     WMI = win32com.client.GetObject('winmgmts:')
    1056     processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name)
    1057     if len(processCodeCov) > 0:  # 判断操作 www.iplaypy.com
    1058         return 1
    1059     else:
    1060         return 0
    1061 def main():
    1062     time.sleep(5)
    1063     judge_app_online_login_and_app_front()
    1064     judgecookie()
    1065     logintoigxe()
    1066     global itemcount
    1067     global fbuyprice
    1068     global buyprice
    1069     global driver
    1070     global nofound
    1071     global getcount
    1072     global first_url_count
    1073     global sleep1
    1074     global sleep2
    1075     global count
    1076     global itemsdict
    1077     global appdriver
    1078     global nowprice
    1079     global htmlid_dict
    1080     global goodsid_dict
    1081     itemcount = calc_count()
    1082     log('缓冲阶段:')
    1083     #driver.get("https://www.bilibili.com/")
    1084     #for i in range(1, 200):
    1085     #    driver.find_element_by_xpath('/html/body').send_keys(Keys.DOWN)
    1086     #time.sleep(10)
    1087     driver.set_page_load_timeout(0.5)
    1088     for i in range(0,1):
    1089         kk = open('buffdataurl', 'r', encoding='utf-8')
    1090         with open('buyforself.txt', 'w', encoding='utf-8') as wtf:
    1091             pass
    1092         first_url_count = 1
    1093         count = 810
    1094         thread = []
    1095         for i in range(0, count):
    1096             tradeurl = kk.readline()
    1097             hisurl = kk.readline()
    1098             itemname = kk.readline()
    1099             t = threading.Thread(target=getbuyurl_hc,
    1100                                  args=(tradeurl, hisurl, itemname,))
    1101             thread.append(t)
    1102         for i in range(0, count):
    1103             time.sleep(sleep1)
    1104             thread[i].start()
    1105         for i in range(0, count):
    1106             thread[i].join()
    1107         kk.close()
    1108         sleep1=0.15
    1109     for i in range(0, 3):
    1110         sleep2 = 0
    1111         count = 775
    1112         thread = []
    1113         ff = open('igxedataurl', 'r')
    1114         for i in range(0, count):
    1115             t = threading.Thread(target=igxegetdict,
    1116                                  args=(ff,))
    1117             thread.append(t)
    1118         for i in range(0, count):
    1119             time.sleep(sleep2)
    1120             thread[i].start()
    1121         for i in range(0, count):
    1122             thread[i].join()
    1123         ff.close()
    1124     log('脚本开始:')
    1125     while 1:
    1126         try:
    1127             judge_app_online_login_and_app_front()
    1128             try:
    1129                 driver.set_page_load_timeout(10)
    1130                 driver.get('https://www.igxe.cn/sell/730')
    1131             except Exception as e:
    1132                 print(e)
    1133                 log("火狐加载超时")
    1134             if not check_exsit("firefox.exe"):
    1135                 driver = webdriver.Firefox()
    1136                 driver.set_page_load_timeout(10)
    1137                 driver.maximize_window()
    1138                 logintoigxe()
    1139             driver.set_page_load_timeout(0.5)
    1140             judgecookie()
    1141             count = 775
    1142             thread = []
    1143             ff = open('igxedataurl', 'r')
    1144             for i in range(0, count):
    1145                 t = threading.Thread(target=igxegetdict,
    1146                                      args=(ff,))
    1147                 thread.append(t)
    1148             for i in range(0, count):
    1149                 time.sleep(sleep2)
    1150                 thread[i].start()
    1151             for i in range(0, count):
    1152                 thread[i].join()
    1153    #        log("000000000000000")
    1154             ff.close()
    1155             kk = open('buffdataurl', 'r', encoding='utf-8')
    1156             with open('buyforself.txt', 'w', encoding='utf-8') as wtf:
    1157                 pass
    1158             first_url_count = 1
    1159             count = 810
    1160             thread = []
    1161             for i in range(0,count):
    1162                 tradeurl = kk.readline()
    1163                 hisurl = kk.readline()
    1164                 itemname = kk.readline()
    1165                 t = threading.Thread(target=getbuyurl,
    1166                                      args=(tradeurl,hisurl,itemname,))
    1167                 thread.append(t)
    1168             for i in range(0, count):
    1169                 time.sleep(sleep1)
    1170                 thread[i].start()
    1171             for i in range(0, count):
    1172                 thread[i].join()
    1173             kk.close()
    1174  #           log("111111111111111")
    1175             goodsid_dict = {}
    1176             htmlid_dict = {}
    1177             igxe = open("igxedataurl", "r", encoding='utf-8')
    1178             for i in range(0, 775):
    1179                 first = igxe.readline()
    1180                 second = igxe.readline()
    1181                 first = first.replace("
    ", "")
    1182                 first = first.replace('https://www.igxe.cn/product/get_product_sales_history/730/', '')
    1183                 goodsid_dict[first] = 1
    1184             times = 0
    1185             igxe.close()
    1186             updatealiypay()
    1187             for i in range(0,35):
    1188                 try:
    1189                     driver.get('https://www.igxe.cn/product/730/3955') #
    1190                 except:
    1191                     pass
    1192                 appdriver.tap([(971, 2150), (971, 2150)], 1)
    1193                 appdriver.tap([(971, 2150), (971, 2150)], 1)
    1194                 appdriver.tap([(779, 2150), (779, 2150)], 1)
    1195                 appdriver.tap([(779, 2150), (779, 2150)], 1)
    1196                 findmainweb()
    1197                 fbuyprice = 0
    1198                 nofound = 0
    1199                 getcount = 0
    1200                 sleep1=0.0
    1201                 sleep2=0
    1202                 now = datetime.now()
    1203                 for tmp in range(0,20):
    1204                     try:
    1205                         judgetime()
    1206                         times += 1
    1207                         tradeurl = "https://www.igxe.cn/csgo/730?is_buying=0&is_stattrak%5B%5D=0&is_stattrak%5B%5D=0&sort=3&ctg_id=0&type_id=0&page_no=1&page_size=40&rarity_id=0&exterior_id=0&quality_id=0&capsule_id=0&_t=1566486610641"
    1208                         point = requests.get(tradeurl, headers=header, timeout=1)
    1209                         pattern = re.compile('"/product/730/.*?"')
    1210                         result1 = pattern.findall(point.text)
    1211                         sum = 0
    1212                         for i in result1:
    1213                             goodsid = i.replace('"/product/730/', '')
    1214                             goodsid = goodsid.replace('"', "")
    1215                             if not goodsid in htmlid_dict.keys() or htmlid_dict[goodsid] == 0:
    1216                                 htmlid_dict[goodsid] = 1
    1217                                 sum += 1
    1218                                 if goodsid in goodsid_dict.keys():
    1219                                     url = "https://www.igxe.cn/product/trade/730/" + goodsid
    1220                                     igxegetbuyurl(url)
    1221                         if times != 1 and sum == 40:
    1222                             htmlid_dict = {}
    1223                             times = 0
    1224                         tradeurl = "https://www.igxe.cn/csgo/730?is_buying=0&is_stattrak%5B%5D=0&is_stattrak%5B%5D=0&sort=3&ctg_id=0&type_id=0&page_no=2&page_size=40&rarity_id=0&exterior_id=0&quality_id=0&capsule_id=0&_t=1566559812876"
    1225                         point = requests.get(tradeurl, headers=header, timeout=1)
    1226                         pattern = re.compile('"/product/730/.*?"')
    1227                         result1 = pattern.findall(point.text)
    1228                         for i in reversed(result1):
    1229                             goodsid = i.replace('"/product/730/', '')
    1230                             goodsid = goodsid.replace('"', "")
    1231                             if goodsid in htmlid_dict.keys() and htmlid_dict[goodsid] == 1:
    1232                                 htmlid_dict[goodsid] = 0
    1233                     except Exception as e:
    1234                         timeprint(e)
    1235                 end = datetime.now()
    1236         except:
    1237             pass
    1238 nowprice = 0
    1239 nowtime = 0
    1240 endtime = 0
    1241 fbuyprice = 0
    1242 buyprice = 0
    1243 nofound = 0
    1244 sleep1 = 0.25 #0.05 0.25
    1245 sleep2 = 0.0 #0.03 0.1
    1246 defearnrate = 8.5
    1247 hisprice = 0
    1248 getcount = 0
    1249 first_url_count = 0
    1250 itemsdict = {}
    1251 buff_judge_exist = {}
    1252 itemcount = 0
    1253 header = {
    1254 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/71.0.3578.98 Safari/537.36',
    1255 }
    1256 cookies = 
    1257 cookies = 
    1258     []
    1259 appcookies = 
    1260     []
    1261 cookies1 = {}
    1262 desired_caps = {
    1263     'platformName': 'Android',
    1264     'deviceName': 'ea50da1f',
    1265     'platformVersion': '9',
    1266     'appPackage': 'cn.igxe',
    1267     'appActivity': 'cn.igxe.ui.MainActivity',
    1268     'noReset':'true',
    1269     'fullReset'  : 'false',
    1270     'disableAndroidWatchers':'true'
    1271 }
    1272 itchat.auto_login(hotReload=True,exitCallback=after_logout)
    1273 send_userid='Miraculous_B'
    1274 itcaht_user_name = itchat.search_friends(name=send_userid)[0]['UserName']
    1275 buyinfo = 0
    1276 driver = webdriver.Firefox()
    1277 driver.maximize_window()
    1278 driver.set_page_load_timeout(10)
    1279 os.system('taskkill /f /im "adb.exe"')
    1280 appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
    1281 appdriver.quit()
    1282 appdriver = appwebdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动APP
    1283 if __name__ == '__main__':
    1284     freeze_support()
    1285     main()
    View Code
  • 相关阅读:
    spring注解实现业务层事务管理,当业务层自调用时,事务失效问题解决
    spring的事务
    maven创建web项目
    eclipse安装最新版svn
    .ncx文件剖析
    关闭MongoDB服务的几种方法
    mongodb添加验证用户 删除用户
    高性能kv存储之Redis、Redis Cluster、Pika:如何应对4000亿的日访问量?
    Python中msgpack库的使用
    彻底理解一致性哈希算法(consistent hashing)
  • 原文地址:https://www.cnblogs.com/MiraculousB/p/12274811.html
Copyright © 2020-2023  润新知