python实现爬取免费简历模板网站-创新互联
这期内容当中小编将会给大家带来有关python 实现爬取免费简历模板网站,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
创新互联建站-专业网站定制、快速模板网站建设、高性价比韶关网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式韶关网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖韶关地区。费用合理售后完善,10年实体公司更值得信赖。代码
# 免费的简历模板进行爬取本地保存 # /tupian/20230522/free.html # /tupian/20230522/free_2.html import requests from lxml import etree import os dirName = './resumeLibs' if not os.path.exists(dirName): os.mkdir(dirName) headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' } url = 'http://sc.chinaz.com/jianli/free_%d.html' for page in range(1,2): if page == 1: new_url = '/tupian/20230522/free.html' else: new_url = format(url%page) page_text = requests.get(url=new_url,headers=headers).text tree = etree.HTML(page_text) a_list = tree.xpath('//div[@id="container"]/div/p/a') for a in a_list: a_src = a.xpath('./@href')[0] a_title = a.xpath('./text()')[0] a_title = a_title.encode('iso-8859-1').decode('utf-8') # 爬取下载页面 page_text = requests.get(url=a_src,headers=headers).text tree = etree.HTML(page_text) dl_src = tree.xpath('//div[@id="down"]/div[2]/ul/li[8]/a/@href')[0] resume_data = requests.get(url=dl_src,headers=headers).content resume_name = a_title resume_path = dirName + '/' + resume_name + '.rar' with open(resume_path,'wb') as fp: fp.write(resume_data) print(resume_name,'下载成功!')
分享题目:python实现爬取免费简历模板网站-创新互联
本文来源:http://azwzsj.com/article/coides.html