当前位置:网站首页>Crawler small operation
Crawler small operation
2022-06-28 09:54:00 【Pert-】
take reponse The content is displayed in Chinese , And then str To dict
res=response.content.decode("unicode_escape")
res_dict=json.loads(res)
obtain token( Look yes localStorage still SessionStorage), need sleep Wait for a while token Pass it on to get
token = self.driver.execute_script('return localStorage.getItem("token");')
print('\ntoken by :%s\n'%token)
obtain cookie
# obtain cookie
cookie_tag = self.driver.get_cookies()
# print(cookie_tag)
# Handle cookie In the format you need
cookie = cookie_tag[0]['name'] + '=' + cookie_tag[0]['value']
print('\ncookie by :%s\n'%cookie)
Read 、 Write file garbled
### Read
f=open('{}'.format(file_catalogue+'/'+file_list[0]),mode='r',encoding='utf-8',errors='ignore')
contentJson=json.load(f)
print(contentJson)
### write in
with open('student.json',mode='w',encoding='utf8') as f:
json.dump(jsonA,f,ensure_ascii=False,index=2) #ensure_ascii=False Don't let Chinese characters turn into ASCII
#f.write(jsonA) # It is not allowed to write... In the form of ordinary file Because the suffix is json
Make the dictionary easier to view
print(json.dumps(dict_data,indent=1,ensure_ascii=False))
边栏推荐
- Redis sentinel cluster main database failure data recovery ideas # yyds dry goods inventory #
- P2394 yyy loves Chemistry I
- Wechat applet development log
- Application of X6 in data stack index management
- Global exception handlers and unified return results
- 优秀笔记软件盘点:好看且强大的可视化笔记软件、知识图谱工具Heptabase、氢图、Walling、Reflect、InfraNodus、TiddlyWiki
- 装饰模式(Decorator)
- PMP needs to master its own learning methods
- DolphinScheduler使用系统时间
- 理想中的接口自动化项目
猜你喜欢

纵观jBPM从jBPM3到jBPM5以及Activiti

理想中的接口自动化项目

Data visualization makes correlation analysis easier to use

mysql打不开,闪退

老板叫我写个APP自动化--Yaml文件读取--内附整个框架源码

Linux下安装redis 、Windows下安装redis(超详细图文教程)

Explain final, finally, and finalize

Static page of pinyougou mall

Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"

An error is reported when uninstalling Oracle
随机推荐
English translation plug-in installation of idea
PMP考试重点总结九——收尾
用 Compose 实现个空调,为你的夏日带去清凉
云服务器MYSQL查询速度慢
Key summary V of PMP examination - execution process group
线程和进程
多线程-并发并行-线程进程
Regular verification of mobile phone number and email [easy to understand]
This article explains in detail the difficult problems and solutions faced by 3D cameras
The digital human industry is about to break out. What is the market pattern?
2020-10-27
The concept of "tree structure" perfectly interprets the primary and secondary of things
Differences between task parameter types inout and ref
[ybtoj advanced training guidance] class roll call [string hash]
PMP Exam key summary IX - closing
Interpretation of new products: realm launched GT neo2 Dragon Ball customized version
P2394 yyy loves Chemistry I
如图 用sql行转列 图一原表,图二希望转换后
异常处理4种方法
Write a simple timeline