我用selenium先登录主页再添加cookies,然后添加的时候就报错了。cookies是我上次登录时保存的
会不会是因为我尝试爬淘宝的原因?
cookie = bro.get_cookies() #print(cookie) jsonCookies = json.dumps(cookie) with open( qqhomepage.json , w ) as f: f.write(jsonCookies) str = with open( qqhomepage.json , r , encoding= utf-8 ) as f: listCookies = json.loads(f.read()) cookie = [item[ name ] + = + item[ value ] for item in listCookies] cookiestr = ; .join(item for item in cookie) print(cookiestr) headers = { Cookie :cookiestr, User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 }
自己改吧
谢谢,我看看
前面你自己登陆的要写,其他地方你看着改就ok
好的