Pythonpy 爬取汽车之家新闻案例import requests from bs4 import BeautifulSoup response = requests.get("https://www.autohome.com.cn/news/") # 1. content /text 的区别 # print(response.content) # content 拿到的字节 response作者王明昌发布时间2019-11-17最后更新2019-11-17复制import requests from bs4 import BeautifulSoup response = requests.get("https://www.autohome.com.cn/news/") # 1. content /text 的区别 # print(response.content) # content 拿到的字节 response.encoding = 'gbk' # print(response.text) # text 拿到的文本信息 soup = BeautifulSoup(response.text,'html.parser') # tag = soup.find(id='auto-channel-lazyload-article') # 找唯一的值,缩小范围 # h3 = tag.find(name='h3',class_ ='') # class是关键词所以要加下划线, 或者使用下面的方式 # h3 = tag.find(name='h3',attrs= {'class':''}) # # print(h3) # 链式写法 li_list = soup.find(id='auto-channel-lazyload-article').find_all(name='li') for li in li_list: title = li.find('h3') #获取标题 if not title:# 如果为null,跳出 continue title = title.text summary = li.find("p").text url = li.find("a").get('href') img = li.find("img").get('src') print(img) # 保存图片 res = requests.get(img) file_name = "%s.jpg"%(title,) with open(file_name,'wb') as f: f.write(res.content) #保存字节内容
2019-11-06分享几个在线获取临时邮箱10 分钟邮箱 http://www.bccto.me/ 10 分钟邮箱 https://temp-mail.org/zh/ 10 分钟邮箱 https://10minutemail.net/?lan
2018-03-27转载 | 手把手教你vps搭建属于自己的ss教程,开始科学上网吧手把手教你vps搭建属于自己的ss教程,开始科学上网吧(利用vultr,看youtube1080p无压力) 一开始本人也是小白一个,但是之前用过各种fq方法,都不是很理想,前些天终于开始搭建自己通
2018-06-02linux | 常用命令(四)服务进程 实时观察cpu/进程/内存: top (q键退出) load average: 0.05, 0.11, 0.08 1分钟 5分钟 15分钟 平均负载 %Cpu(s): 0.7 us, 1.4
2018-06-05伪静态/重定向学习整理伪静态只是改变了url的表现形式,实际上还是动态页面 伪静态有真实静态页面一样的SEO 我们普遍使用重定向来实现伪静态 重定向 http协议中的3XX(主要有302/303) 例: 1.修改apach
2019-11-06新建composer包(命令注释)composer init 提示进行配置 packagist 信息: 输入项目命名空间 name:其实就是 packagist 名称,建议 github 用户名/项目名称,leesin/compose