当前位置: 首页 > news >正文

网站开发 php 书籍 推荐正规的关键词优化软件

网站开发 php 书籍 推荐,正规的关键词优化软件,丰台网站建设公司,物联网平台排名案例需求: 1.爬取腾讯社招的数据(搜索 | 腾讯招聘)包括岗位名称链接时间公司名称 2.爬取所有页(翻页) 3.利用jsonpath进行数据解析 4.保存数据:txt文本形式和excel文件两种形式 解析: 1.分…

案例需求:

1.爬取腾讯社招的数据(搜索 | 腾讯招聘)包括岗位名称+链接+时间+公司名称

2.爬取所有页(翻页)

3.利用jsonpath进行数据解析

4.保存数据:txt文本形式和excel文件两种形式

解析:

1.分析该网站同步还是异步?——异步(查看xhr)

2.找到正确的数据包——看响应内容

248be5ef208a40bf8eed9b2db2160d66.png

3.复制请求地址

https://careers.tencent.com/tencentcareer/api/post/Query?timestamp=1727929418908&countryId=&cityId=&bgIds=&productId=&categoryId=&parentCategoryId=&attrId=&keyword=&pageIndex=3&pageSize=10&language=zh-cn&area=cn

4.删除不必要的,找到正确的(可删可不删)

https://careers.tencent.com/tencentcareer/api/post/Query?

5.该网站反爬手段比较强,给其进行伪装

9294c408ea7e47529546f4b23da1cfef.png

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
}
data = {'timestamp': '1648355434381','countryId': '','cityId': '','bgIds': '','productId': '','categoryId': '','parentCategoryId': '40001','attrId': '','keyword': '','pageIndex': i,'pageSize': '10','language': 'zh-cn','area': 'cn'
}

6.保存在excel文件中,创建对象

wb = workbook.Workbook()  # 创建Excel对象
ws = wb.active  # 激活当前表
ws.append(['职称', '链接', '时间', '公司名称'])

进行excel保存

def save_excel(z,l,s,g):my_list = [z,l,s,g]  # 以列表形式写入ws.append(my_list)wb.save('腾讯社招.xlsx')

进行本地文本保存

def save_text(n,u,t,p):with open('腾讯社招.txt','a',encoding='utf-8')as f:f.write(n+'\n')f.write(u+'\n')f.write(t+'\n')f.write(p+'\n')

7.使用jsonpath解析数据

names = jsonpath(r, '$..RecruitPostName')
urls = jsonpath(r, '$..PostURL')
times = jsonpath(r, '$..LastUpdateTime')
pronames = jsonpath(r, '$..ProductName')

8.处理解析的数据

for name, url, time, protime in zip(names, urls, times, pronames):# print(name,url,time,protime)save_text(name, url, time, protime)save_excel(name, url, time, protime)

9.翻页分析

c6568a8fa0ff4918a4f0b2b25562e15a.png

for i in range(1,6):print("第{}页已经保存完毕!!!".format(i))# url = 'https://careers.tencent.com/search.html'data = {'timestamp': '1648355434381','countryId': '','cityId': '','bgIds': '','productId': '','categoryId': '','parentCategoryId': '40001','attrId': '','keyword': '','pageIndex': i,'pageSize': '10','language': 'zh-cn','area': 'cn'}

示例代码:

import requests
from jsonpath import jsonpath
from openpyxl import workbook
import time
#"http://careers.tencent.com/jobdesc.html?postId=1685827130673340416"
def get_data():response = requests.get(url, headers=headers, params=data)r = response.json()return rdef parse_data(r):names = jsonpath(r, '$..RecruitPostName')urls = jsonpath(r, '$..PostURL')times = jsonpath(r, '$..LastUpdateTime')pronames = jsonpath(r, '$..ProductName')for name, url, time, protime in zip(names, urls, times, pronames):# print(name,url,time,protime)save_text(name, url, time, protime)save_excel(name, url, time, protime)
# 保存数据
def save_text(n,u,t,p):with open('腾讯社招.txt','a',encoding='utf-8')as f:f.write(n+'\n')f.write(u+'\n')f.write(t+'\n')f.write(p+'\n')def save_excel(z,l,s,g):my_list = [z,l,s,g]  # 以列表形式写入ws.append(my_list)wb.save('腾讯社招.xlsx')
if __name__ == '__main__':wb = workbook.Workbook()  # 创建Excel对象ws = wb.active  # 激活当前表ws.append(['职称', '链接', '时间', '公司名称'])url = 'https://careers.tencent.com/tencentcareer/api/post/Query?'headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'}for i in range(1,6):print("第{}页已经保存完毕!!!".format(i))# url = 'https://careers.tencent.com/search.html'data = {'timestamp': '1648355434381','countryId': '','cityId': '','bgIds': '','productId': '','categoryId': '','parentCategoryId': '40001','attrId': '','keyword': '','pageIndex': i,'pageSize': '10','language': 'zh-cn','area': 'cn'}time.sleep(2)h=get_data()parse_data(h)

 运行结果:

5b297631782349a3ab87c4ec5bea1552.png

2280fac13247497694425f4fa7d9f1bd.png

e4b08dce72b94653b76aa69e630d34b5.png

同样也可以添加代理来进行

添加代理

zhima_api = 'http://http.tiqu.letecs.com/getip3?num=1&type=1&pro=&city=0&yys=0&port=1&pack=225683&ts=0&ys=0&cs=0&lb=1&sb=0&pb=4&mr=1&regions=&gm=4'
proxie_ip = requests.get(zhima_api).json()['data'][0]
print(proxie_ip)
# 将提取后的IP处理成字典形式 构造完整HTTP代理
proxies = {'http': 'http://' + str(proxie_ip['ip']) + ':' + str(proxie_ip['port']),#'https': 'https://' + str(proxie_ip['ip']) + ':' + str(proxie_ip['port'])
}

 

http://www.ds6.com.cn/news/1011.html

相关文章:

  • 订餐网站系统建设方案seo关键词排名技巧
  • 京东企业的电子网站建设优化服务
  • wordpress链接跳转等待专业网站seo推广
  • 网站静态界面挖取windows优化大师下载安装
  • 做网站干什么百度账号注册中心
  • 某个产品营销推广方案seo在线优化排名
  • 大冶seo网站优化排名推荐巩义关键词优化推广
  • 网站建设公司浩森宇特优化排名推广技术网站
  • 网站制作计划seo技术培训价格表
  • 贷款公司通过做网站来给予平台贷款企业推广策划方案
  • 北京专业网站翻译影音字幕翻译速记速记速记快而高效兰州seo公司
  • 建设b2b网站的多少钱杭州网络推广公司
  • 做网站搞流量挂联盟广告变现企业网站怎么做
  • WordPress女人网模板seo怎么收费seo
  • 广西建网站公司合肥优化推广公司
  • 滨海县网站建设seo技术博客
  • 网站 动态 静态seo排名影响因素主要有
  • 网站建设培训龙岗网络推广合作资源平台
  • 苏州市做网站百度教育app
  • 做鸭网站谷歌seo代运营
  • 电脑当网站空间自媒体发稿
  • 网页设计代码模板适应手机界面宁波优化网站排名软件
  • 区块链网站开发windows优化大师绿色版
  • 网站建设开发哪家质量好网站建设费用明细表
  • 深圳网站美化百度关键词搜索指数
  • 天元建设集团有限公司董事长seo俱乐部
  • 优秀服装网站设计百度高级搜索功能
  • 做网站建设的电销网站推广的作用
  • 网站建设 风险天津百度百科
  • 廊坊网站建设品牌舆情分析报告