当前位置:网站首页>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))
边栏推荐
- 再见!IE浏览器,这条路由Edge替IE继续走下去
- File operations in QT
- 股票开户用中金证券经理发的开户二维码安全吗?知道的给说一下吧
- 通过PyTorch构建的LeNet-5网络对手写数字进行训练和识别
- MySQL基础知识点总结
- Matplotlib attribute and annotation
- [ybtoj advanced training guidance] class roll call [string hash]
- PMP考试重点总结五——执行过程组
- How to reduce the risk of project communication?
- flink cep 跳过策略 AfterMatchSkipStrategy.skipPastLastEvent() 匹配过的不再匹配 碧坑指南
猜你喜欢

Explain final, finally, and finalize

Matplotlib属性及注解

English translation plug-in installation of idea

Adapter mode

数字人行业爆发在即,市场格局几何?

A classic JVM class loaded interview question class singleton{static singleton instance = new singleton(); private singleton() {}

函数的分文件编写

Composite pattern

如何查看谷歌浏览器保存的网页密码

Numpy array: join, flatten, and add dimensions
随机推荐
Settings of gift giving module and other custom controls in one-to-one video chat system code
卸载oracle报错
爬虫小操作
English translation plug-in installation of idea
An error is reported when uninstalling Oracle
通过PyTorch构建的LeNet-5网络对手写数字进行训练和识别
Au revoir! Navigateur ie, cette route Edge continue pour IE
剑指Offer | 斐波那契数列
Summary of MySQL basic knowledge points
Matplotlib属性及注解
Bridge mode
Multithreading concurrent parallel threaded process
线程和进程
dotnet 使用 Crossgen2 对 DLL 进行 ReadyToRun 提升启动性能
Redis sentinel cluster main database failure data recovery ideas # yyds dry goods inventory #
Virtual machine 14 installing win7 (Figure tutorial)
Sword finger offer | linked list transpose
Installing redis under Linux and windows (ultra detailed graphic tutorial)
On the influence of small program on the digitalization of media industry
PMP考试重点总结五——执行过程组