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

吉林网站优化百度收录入口提交查询

吉林网站优化,百度收录入口提交查询,如何做html网站,wordpress 简码插件文章目录 力扣竞赛勋章介绍竞赛评分算法脚本(本文的重点内容)运行结果 代码修改自:https://leetcode.cn/circle/discuss/6gnvEj/ 原帖子的代码无法正常运行。 力扣竞赛勋章介绍 https://leetcode.cn/circle/discuss/0fKGDu/ 如果你想知道自…

文章目录

  • 力扣竞赛勋章介绍
  • 竞赛评分算法
  • 脚本(本文的重点内容)
  • 运行结果

代码修改自:https://leetcode.cn/circle/discuss/6gnvEj/
原帖子的代码无法正常运行。

力扣竞赛勋章介绍

https://leetcode.cn/circle/discuss/0fKGDu/

在这里插入图片描述

如果你想知道自己上多少分可以拿到对应的勋章,那么篇文章会解决你的问题!

竞赛评分算法

https://leetcode.cn/circle/article/neTUV4/

脚本(本文的重点内容)

#!/usr/bin/env python3import json
import sysimport requests# 力扣目前勋章的配置
RATING = 1600       # 从1600分以上才开始算人
GUARDIAN = 0.05
KNIGHT = 0.25
# 查询的地址为全国还是全球?很关键
GLOBAL = False
# 二分查找的右端点(可自调)
RIGHT = 3000def fetch_lastest_ranking(mode):l, r = 1, RIGHTretry_cnt = 0ansRanking = Nonewhile l < r:cur_page = (l + r + 1) // 2try:payload = RankingCrawler._REQUEST_PAYLOAD_TEMPLATE.copy()payload['query'] = payload['query'].replace('page: 1', 'page: {}'.format(cur_page))resp = requests.post(RankingCrawler.URL,headers={'Content-type': 'application/json'},json=payload).json()resp = resp['data']['localRanking'] if not GLOBAL else resp['data']['globalRanking']# no more dataif len(resp['rankingNodes']) == 0:breakif not mode:top = int(resp['rankingNodes'][0]['currentRating'].split('.')[0])if top < RATING:r = cur_page - 1else:l = cur_pageansRanking = resp['rankingNodes']else:top = int(resp['rankingNodes'][0]['currentGlobalRanking'])if top > mode:r = cur_page - 1else:l = cur_pageansRanking = resp['rankingNodes']print('The first contest current rating in page {} is {} .'.format(cur_page, resp['rankingNodes'][0]['currentRating']))retry_cnt = 0except:print(f'Failed to retrieved data of page {cur_page}...retry...{retry_cnt}')retry_cnt += 1ansRanking = ansRanking[::-1]last = Noneif not mode:while ansRanking and int(ansRanking[-1]['currentRating'].split('.')[0]) >= 1600:last = ansRanking.pop()else:while ansRanking and int(ansRanking[-1]['currentGlobalRanking']) <= mode:last = ansRanking.pop()return lastclass RankingCrawler:URL = 'https://leetcode.com/graphql' if GLOBAL else 'https://leetcode-cn.com/graphql'_REQUEST_PAYLOAD_TEMPLATE = {"operationName": None,"variables": {},"query":r'''{localRanking(page: 1) {totalUsersuserPerPagerankingNodes {currentRatingcurrentGlobalRanking}}}''' if not GLOBAL elser'''{globalRanking(page: 1) {totalUsersuserPerPagerankingNodes {currentRatingcurrentGlobalRanking}}}'''}if __name__ == "__main__":crawler = RankingCrawler()ans = fetch_lastest_ranking(0)n = int(ans['currentGlobalRanking'])guardian = fetch_lastest_ranking(int(GUARDIAN * n))knight = fetch_lastest_ranking(int(KNIGHT * n))if not GLOBAL:guardian['currentCNRanking'] = guardian['currentGlobalRanking']guardian.pop('currentGlobalRanking')knight['currentCNRanking'] = knight['currentGlobalRanking']knight.pop('currentGlobalRanking')print("Done!")print()print("目前全{}1600分以上的有{}人".format("球" if GLOBAL else "国", n))print("根据这个人数,我们得到的Guardian排名及分数信息为:{}".format(guardian))print("根据这个人数,我们得到的Knight排名及分数信息为:{}".format(knight))sys.exit()

运行结果

运行结果大致如下:

C:\Users\fengwei\anaconda3\python.exe D:/study_folder/研究生课程/深度学习/my_work/论文分享/leetcode.py
The first contest current rating in page 1501 is 1557 .
The first contest current rating in page 751 is 1676 .
The first contest current rating in page 1126 is 1603 .
The first contest current rating in page 1313 is 1578 .
Failed to retrieved data of page 1219...retry...0
The first contest current rating in page 1219 is 1589 .
The first contest current rating in page 1172 is 1596 .
The first contest current rating in page 1149 is 1599 .
The first contest current rating in page 1137 is 1601 .
The first contest current rating in page 1143 is 1600 .
The first contest current rating in page 1146 is 1599 .
The first contest current rating in page 1144 is 1600 .
The first contest current rating in page 1145 is 1600 .
The first contest current rating in page 1501 is 1557 .
The first contest current rating in page 751 is 1676 .
The first contest current rating in page 376 is 1821 .
The first contest current rating in page 188 is 1978 .
The first contest current rating in page 94 is 2143 .
The first contest current rating in page 47 is 2308 .
The first contest current rating in page 70 is 2216 .
The first contest current rating in page 58 is 2260 .
The first contest current rating in page 64 is 2238 .
The first contest current rating in page 61 is 2249 .
The first contest current rating in page 59 is 2257 .
The first contest current rating in page 1501 is 1557 .
The first contest current rating in page 751 is 1676 .
The first contest current rating in page 376 is 1821 .
The first contest current rating in page 188 is 1978 .
The first contest current rating in page 282 is 1887 .
The first contest current rating in page 329 is 1851 .
The first contest current rating in page 305 is 1870 .
The first contest current rating in page 293 is 1878 .
The first contest current rating in page 287 is 1883 .
The first contest current rating in page 290 is 1881 .
The first contest current rating in page 288 is 1882 .
Done!目前全国1600分以上的有28612人
根据这个人数,我们得到的Guardian排名及分数信息为:{'currentRating': '2260', 'currentCNRanking': 1430}
根据这个人数,我们得到的Knight排名及分数信息为:{'currentRating': '1883', 'currentCNRanking': 7153}Process finished with exit code 0

可以看出 1883 以上可以得到 Knight
2260 以上可以得到 Guardian

http://www.hkea.cn/news/27546/

相关文章:

  • 福田做商城网站建设找哪家公司好抖音怎么运营和引流
  • 厘米售卡站怎么做网站禁止搜索引擎收录的方法
  • 网站首页滚动图片怎么做谷歌搜索关键词排名
  • 嵩县网站开发友情链接获取的途径有哪些
  • 国家企业信息公示网(广东)海南快速seo排名优化
  • 高端网站设计 上海徐州seo排名公司
  • 泰安网站建设公司排名石家庄最新消息
  • 域名只做邮箱没网站要备案吗常见的网络推广方式包括
  • 昆山建设局网站360搜索首页
  • 正常做网站多少钱无锡网站制作无锡做网站
  • php做网站csdn网站seo公司哪家好
  • 今日头条建站工具何鹏seo
  • wordpress 培训模板优化落实疫情防控新十条
  • 关于做外汇现货的网站太原整站优化排名外包
  • 星悦做任务网站是新网站百度收录
  • 十大营销网站seo关键词查询工具
  • 怎么查询网站所有关键词靠谱的广告联盟
  • 超酷的网站设计磁力搜索引擎
  • 网站建设写程序用什么软件成都疫情最新消息
  • 做网站需要什么资金2022今天刚刚发生地震了
  • 建设网站费用主要包括哪些google商店
  • 专注邯郸建设手机网站贴吧友情链接在哪
  • 网站备案拍照背景志鸿优化网官网
  • 网站百度知道怎么做推广网站搜索引擎优化的方法
  • 网站建设注意哪些问题sem和seo是什么职业岗位
  • 一_建设网站前的市场分析奶茶软文案例300字
  • 做网站智能工具江阴企业网站制作
  • 怎么看网站有没有做推广大数据营销系统多少钱
  • 广东工厂搜索seoseo平台优化服务
  • 网站开发平台 eclipseseo网站推广案例