import time import requests from selenium import webdriver from selenium.webdriver.common.by import By browser = webdriver.Edge() browser.maximize_window() url = "https://m.xiaoshuopu.com/user/login.html" browser.get(url) username_input = browser.find_element(By.XPATH, '//input[@id="username"]') username_input.send_keys('xxx') password_input = browser.find_element(By.XPATH, '//input[@id="password"]') password_input.send_keys('xxx') login_input = browser.find_element(By.XPATH, '//input[@class="login_in"]') login_input.click() selenium_cookie = browser.get_cookies() print(selenium_cookie) time.sleep(10) browser.quit() requests_cookie = {cookie['name']:cookie['value'] for cookie in selenium_cookie} print(requests_cookie) response = requests.get(url, cookies=requests_cookie) print(response.text)
标签:登录,selenium,cookie,import,input,requests,模拟,browser From: https://www.cnblogs.com/zhzhang/p/18222733