def detail(name, companyName, workingExp, number, type): detailUrl = f'https://xiaoyuan.zhaopin.com/job/{number}?jobSourceType={type}&jobfrom=practicesearch&productId=1&channelId=2' res = requests.get(detailUrl, headers=headers) # print(res.text) result = re.findall(r'<div class="describe">(.*?)</div>', res.text, re.S) # print(result) if result: content = result[0].replace('<br>', '') zhice = re.findall(r'职责(.*?)。', content) zige = re.findall(r'任职(.*?)。', content) zhice = ''.join(zhice) zige = ''.join(zige) writer.writerow([name, companyName, workingExp, zhice, zige,content]) print('已存入') else: writer.writerow([name, companyName, workingExp,result]) print('报错!!')
时间: 2023-06-24 19:08:33 浏览: 59
这段代码是一个函数,接受五个参数,分别是职位名称(name)、公司名称(companyName)、工作经验(workingExp)、职位编号(number)和职位类型(type)。它的功能是从智联招聘的网页中爬取职位的详细信息,包括职责、任职要求和职位描述,并将这些信息写入一个 CSV 文件中。
具体实现方式是通过 requests 库发送 GET 请求,获取职位详情页的 HTML 文本,然后使用正则表达式从中提取出职责(zhice)、任职要求(zige)和职位描述(content),最后将这些信息写入 CSV 文件中。如果提取失败,则只将职位名称、公司名称和工作经验写入 CSV 文件,并输出错误信息。
相关问题
<u-cell-group class="list" :border="false"> <u-cell-item :arrow="true" v-for="(child, index2) in child" :key="child.id" @click="navTo('/pages/sys/msg/form')"> <text slot="title" >{{ child.companyName }}</text> </u-cell-item> </u-cell-group> let groups = [...new Set(company2.map(item => item.parentCode))]; let newArr = groups.map(parentCode =>{ let children = company2.filter(item => item.parentCode == parentCode); children.forEach(child => { // 获取当前子项的父项 let parent = company2.find(item => item.parentCode === parentCode); // 将父项的companyName赋值给子项 child.parentName = parent.companyName; }); return children; }); this.child = newArr; console.log(this.child); 如何在text标签里根据夫数组分组显示newArr数组中的子数组的conpanyName
你可以使用 `v-for` 循环渲染 `newArr` 数组中的子数组,并在循环内部使用 `u-cell-group` 和 `u-cell-item` 标签来显示 `companyName`。具体代码如下:
```
<template>
<div>
<u-cell-group :border="false" v-for="(children, index1) in child" :key="index1">
<div slot="title">{{ children[0].parentName }}</div>
<u-cell-item v-for="(item, index2) in children" :key="item.id">
<text>{{ item.companyName }}</text>
</u-cell-item>
</u-cell-group>
</div>
</template>
```
这样就能按照父数组分组显示子数组的 `companyName` 了。
<q-select :options="CompanyCodeOptions" filled multiple v-model="submitData.CompanyCodes" outlined label="公司代码" dense clearable hint="请选择公司代码" @filter="filterCompanyCode" v-model:use-input="useInput" option-label="COMPANYNAME" option-value="COMPANYCODE"> </q-select> vue3 quasar q-select 如何在输入检索值后,当select失焦后,清空检索结果
在Vue 3和Quasar中,你可以使用`@blur`事件来监听`q-select`失焦的事件,并在该事件触发时清空检索结果。下面是一个示例的代码:
```vue
<template>
<q-select
:options="CompanyCodeOptions"
filled
multiple
v-model="submitData.CompanyCodes"
outlined
label="公司代码"
dense
clearable
hint="请选择公司代码"
@filter="filterCompanyCode"
@blur="clearFilterResult" // 添加 @blur 事件监听器
v-model:use-input="useInput"
option-label="COMPANYNAME"
option-value="COMPANYCODE"
>
</q-select>
</template>
<script>
export default {
data() {
return {
CompanyCodeOptions: [],
submitData: {
CompanyCodes: []
},
useInput: true
};
},
methods: {
filterCompanyCode(val) {
// 进行过滤逻辑
// ...
},
clearFilterResult() {
this.CompanyCodeOptions = []; // 清空过滤结果
}
}
};
</script>
```
在上面的代码中,我们通过添加`@blur="clearFilterResult"`来监听`q-select`的失焦事件,并在该事件触发时调用`clearFilterResult`方法来清空过滤结果。在`clearFilterResult`方法中,将`CompanyCodeOptions`数组设置为空数组即可清空过滤结果。
希望这个示例能够帮助到你!如果还有其他问题,请随时提问。