我在网上搜索了很长时间。但没用。请帮助或尝试提供一些如何实现这一目标的想法。
问题的来源第一次,手动滑动输入验证码输入后,网站将返回ACCESS_TOKEN,令牌将在1小时后过期,我是在一小时内刷新页面,当接近一小时到刷新页面,我将返回一个新的令牌,即我将登录一次,后面只需要刷新页面。
但是现在有一个问题,chrome会以某种方式关闭,所以我需要在判断浏览器关闭时重新启动浏览器,然后发布数据如下。
这样的帖子标题:
# read the data in from clipboard copied off stackoverflow
df2 = pd.read_clipboard()
# sum the coats with shoes
dfnoslip = df2[df2.selltype != 'slippers']
dfnoslipnext = dfnoslip.groupby('company', as_index=False).sum()
dfnoslipnext.insert(1, 'selltype', 'shoe+coat')
# get just slippers
dfnocoatshoe = df2.query('selltype != "coat" & selltype != "shoe"')
# combine and sort
dfnewcombine = dfnocoatshoe.append(dfnoslipnext)
dfnewcombine = dfnewcombine.sort_values('company')
dfnewcombine
答案 0 :(得分:1)
import os
import re
import psutil
import seleniumrequests
#判断浏览器状态
def handle_brower_statue():
while True:
brower_list = []
pids = psutil.pids()
pid_name_search = re.compile(r'chrome')
for pid in pids:
p = psutil.Process(pid)
pid_name_chrome = re.search(pid_name_search, p.name())
if pid_name_chrome == None:
pass
else:
brower_list.append(pid)
print len(brower_list)
if len(brower_list) < 8:
for kill_pid in brower_list:
os.system("kill -9 %s" % kill_pid)
access_token = read_access_token()
new_data = {
"nsp_svc":"AppPromote.Developer.getRole",
"access_token":access_token,
"nsp_fmt":"JSON",
"nsp_ts":setting.nsp_ts,
}
new_driver = seleniumrequests.Chrome()
time.sleep(2)
response = new_driver.request('POST','https://api.xxxx.com/rest.php',data=new_data)
print response.text