导入模块:requests, lxml, os
import requests from lxml import etree import os # 创建一个文件夹 def mkdir(path): isExists = os.path.exists(path) if not isExists: print('创建名字叫做', path, '的文件夹') os.makedirs(path) # 获取htm链接,并返回一个完整的htm链接,获取标题 def get_html(url): response = requests.get(url=url,headers=headers) page_text = response.text tree = etree.HTML(page_text) htm_list = tree.xpath('//div[@class="bggray clearfix pt20"]/div[3]//p/a/@href') title = tree.xpath('//div[@class="bggray clearfix pt20"]/div[3]//p/a/text()') resume_htm_list = [] # 添加https头并打包成一个列表 for htm in htm_list: resume_htm = 'https:'+htm resume_htm_list.append(resume_htm) return resume_htm_list, title # 获取rar下载链接 def get_resume(resume_htm_list): # 创建一个列表用来
利用requests, xpath爬取站长网简历模板
于 2022-02-16 15:23:59 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)