摘要: 知识目录 静态网页抓取 Spider_基础总结1_Request(get/post__url传参_headers_timeout)+Reponse Spider_基础总结2_Requests异常 Spider_基础总结3_BeautifulSoup对象+find()+find_all() Spide 阅读全文
posted @ 2020-06-29 17:09 collin_pxy 阅读(95) 评论(0) 推荐(0) 编辑
摘要: # 知识点参见:https://blog.csdn.net/muzico425/article/details/102763176 # 示例:爬取示例网站的首页的评论: # 解析得到的字符串r.text(即 json字符串)可以使用json库来完成解析: import json import req 阅读全文
posted @ 2020-06-29 16:52 collin_pxy 阅读(150) 评论(0) 推荐(0) 编辑
摘要: # session 与 cookie # 可能大家对session已经比较熟悉了,也大概了解了session的机制和原理,但是我们在做爬虫时如何会运用到session呢,就是接下来要讲到的会话保持。 # 首先说一下,为什么要进行会话保持的操作? # requests库的session会话对象可以跨请 阅读全文
posted @ 2020-06-29 14:16 collin_pxy 阅读(186) 评论(0) 推荐(0) 编辑
摘要: import requests from bs4 import BeautifulSoup def gettop250(): headers={ 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (K 阅读全文
posted @ 2020-06-29 13:59 collin_pxy 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 静态网页 抓取实例: import requests from bs4 import BeautifulSoup def gettop250(): headers={ 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKi 阅读全文
posted @ 2020-06-29 11:54 collin_pxy 阅读(94) 评论(0) 推荐(0) 编辑
摘要: # 静态网页在浏览器中展示的内容都在HTML的源码中,但主流网页使用 Javascript时,很多内容不出现在HTML的源代码中,此时仍然使用 # requests+beautifulsoup是不能够成功的,如: # 动态网页的爬取,使用 requests+beautifulsoup是不会成功的: 阅读全文
posted @ 2020-06-29 11:34 collin_pxy 阅读(299) 评论(0) 推荐(0) 编辑