本帖最后由 哈岁NB 于 2023-2-7 12:06 编辑
import requests
from lxml import html
etree = html.etree
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
bro = webdriver.Chrome('D:/技能/chromedriver.exe')
bro.get('https://xiaoyuan.zhaopin.com/')
bro.find_element(By.XPATH,'//*[@id="root"]/div/div[1]/div/div[1]/div[2]/a[1]').click()
sleep(10)
bro.find_element(By.XPATH,'//*[@id="root"]/div[2]/div/div/div[3]/span[2]').click()
sleep(2)
cookies = bro.get_cookies()
bro.quit()
#解析cookie
dic = {}
for cookie in cookies:
dic[cookie['name']] = cookie['value']
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
}
url = 'https://xiaoyuan.zhaopin.com/job/CC407288330J40383568908'
response = requests.get(url=url,headers=header,cookies=dic).text
print(response)
用selenium爬取cookie,怎么爬到cookie就缺少acw_sc__v2这个呢 |