爬虫基础总结3

爬虫基础3

定位js

 使用chrome eventlistener

 search all file中所有关键词

分析js

 添加断点的方式,浏览器会在断点处暂停

 console中尝试js的执行结果

requests小技巧

 requests.utils.dict_from_cookiejar

  cookie转化为字典

 url解码 requests.unils.unquote(url)

 处理ssl证书问题 requests.get()url, verify=False)

 超时 requests.get(url, timeout=3)

 retrying 在函数报错的情况下,用装饰器实现重新执行函数的结果

数据分类

 结构化数据

  json

  xml

 非结构化数据

  html

   re

   xpath

json

 实现python类型和字符串的转化

  json.loads(json_str)

  json.dumps(obj, ensure_ascii=False, indent=2)

   ensure_ascii:让中文正常显示

   indent:实现换行缩进格式化

 实现python类型和包含json类型的文件对象转化

  json.load(fp) fp;类文件对象

  json.dumps(obj,fp,ensure_ascii=Fasle,indent=2)

猜你喜欢

转载自www.cnblogs.com/wsilj/p/12736193.html