提交 c3a6da77 作者: 丁双波

微信公众号列表获取

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