提交 c3a6da77 作者: 丁双波

微信公众号列表获取

上级 6abbf836
......@@ -5,10 +5,11 @@ import random
import pymysql
import requests
import urllib3
from pymysql.converters import escape_string
from base.BaseCore import BaseCore
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
baseCore = BaseCore()
log = baseCore.getLogger()
......@@ -125,6 +126,9 @@ def updateTokeen(token,type):
if type ==1:
#封号了 修改封号时间
cursor_.execute(f"update weixin_tokenCookies set fenghao_time=now() where token={token}")
if type ==3:
#封号了 修改封号时间
cursor_.execute(f"update weixin_tokenCookies set update_time=now() where token={token}")
cnx_.commit()
#token的处理
def updateCookieToken(token,cookies):
......@@ -132,8 +136,7 @@ def updateCookieToken(token,cookies):
cnx_.commit()
#获取token
def getToken():
log.info("获取token")
cursor_.execute(f"select token,cookies from weixin_tokenCookies where fenghao_time < DATE_SUB(NOW(), INTERVAL 2 HOUR) ")
cursor_.execute(f"select token,cookies from weixin_tokenCookies where fenghao_time < DATE_SUB(NOW(), INTERVAL 2 HOUR) order by update_time asc limit 1")
row = cursor_.fetchall()
if row:
pass
......@@ -141,11 +144,10 @@ def getToken():
#没有查到token
return False
return row[random.randint(0, len(row)-1)]
return row[0]
#获取列表数据
def getPageData(dic_url,page):
ip = baseCore.get_proxy()
url_ = dic_url['url_']
origin = dic_url['name']
info_source_code = dic_url['info_source_code']
......@@ -161,6 +163,7 @@ def getPageData(dic_url,page):
if tokenAndCookie:
break
token = tokenAndCookie[0]
log.info(f"获取token到----{token}")
cookies = json.loads(tokenAndCookie[1])
# s.cookies.update(cookies)
......@@ -199,6 +202,8 @@ def getPageData(dic_url,page):
error = [origin, url_, info_source_code, str_t, '其他错误']
insertBadSql(error)
return True
# 修改token使用时间
updateTokeen(token, 3)
# 保存数据到数据库
return insertWxList(dic_url,json_search,page)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论