-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookie
52 lines (45 loc) · 1.64 KB
/
cookie
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json
from selenium import webdriver
import os
from pathlib import Path
def del_file(f): #删除文件
root='K:/zhusc/{}'.format(str(f))
my_file = Path(root)
if my_file.exists():
os.remove(my_file)
del_file("1.txt")
def inputme(content,road): #记事本,输入内容
with open(road,'a+',encoding='utf-8') as f:
f.write(json.dumps(content,ensure_ascii=True))
def readme(str,i): #记事本,读取内容
f=open(str,'r+')
lines=f.readlines()
lines[i]=lines[i].strip('\r\n')
return lines[i]
driver=webdriver.Chrome(r'K:\zhusc\chromedriver.exe')
url="https://www.fslib.com.cn/my"
driver.get(url)
driver.find_element_by_xpath('//*[@id="username"]').send_keys('440602xxxxxxxx1548')
driver.find_element_by_xpath('//*[@id="password"]').send_keys('celiaxxxxxx')
driver.find_element_by_xpath('//*[@id="fm1"]/button').click() #登录
driver.maximize_window()
cookie=driver.get_cookies()
print(cookie)
inputme(cookie,'K:/zhusc/1.txt')
a=driver.find_element_by_xpath("//label[text()='昵称']").text
print(a)
driver.quit()
"""
from lxml import etree
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
cookies=dict(domain="www.fslib.com.cn",httpOnly="true", name="JSESSIONID", path="/", secure="False", value="FCE8733EFBAD4D951F2BE2EE1FE54D25")
url="https://www.fslib.com.cn/my"
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36',
}
data = requests.get(url,headers=headers,cookies=cookies,verify=False).text
s=etree.HTML(data)
print(s.xpath("//label[text()='昵称']/text()"))
"""