前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python 爬取csdn我的个人信息

python 爬取csdn我的个人信息

作者头像
刘鸿运
发布2022-11-22 08:12:17
2410
发布2022-11-22 08:12:17
举报
文章被收录于专栏:奋斗少年
代码语言:javascript
复制
import requests
from bs4 import BeautifulSoup
print("16岁IT职业刘鸿运所写")
'''免登csdn器-刘鸿运'''
csdn_headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"}
csdn_url=f"https://blog.csdn.net/qq_48983948?spm=1000.2115.3001.5343"
resu=requests.get(url=csdn_url,headers=csdn_headers)
csdn_x=BeautifulSoup(resu.text,'lxml')
print("*"*38,"我的基本信息","*"*38)
def csdn_name(info):
    print(f"CSDN用户名:{info[0].get_text()}")
csdn_name(info = csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-t > div.user-profile-head-info-l > div.user-profile-head-info-rr > div.user-profile-head-info-r-t > div > div:nth-child(1)"))
def csdn_passwrod_age(css):
    print(f"我的码龄:{css[0].get_text()}")
csdn_passwrod_age(css=csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-t > div.user-profile-head-info-l > div.user-profile-head-info-rr > div.user-profile-head-info-r-t > div > div.person-code-age > span"))
def csdn_password_age_img(img):
    print(f"码龄图片地址:{img}")
csdn_password_age_img(csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-t > div.user-profile-head-info-l > div.user-profile-head-info-rr > div.user-profile-head-info-r-t > div > div.person-code-age > img"))
def csdn_yuan_wen(number):
    print(f"我的原文章数量:{number[0].get_text()}")
csdn_yuan_wen(csdn_x.select('#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-t > div.user-profile-head-info-l > div.user-profile-head-info-rr > div.user-profile-head-info-r-c > ul > li:nth-child(2) > a > div.user-profile-statistics-num'))
def csdn_fensi(number):
    print(f"我的粉丝量:{number[0].get_text()}")
csdn_fensi(csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-t > div.user-profile-head-info-l > div.user-profile-head-info-rr > div.user-profile-head-info-r-c > ul > li:nth-child(4) > a > div.user-profile-statistics-num"))
def csdn_pai(number):
    print(f"当前csdn排名:{number[0].get_text()}")
csdn_pai(csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-t > div.user-profile-head-info-l > div.user-profile-head-info-rr > div.user-profile-head-info-r-c > ul > li:nth-child(3) > a > div.user-profile-statistics-num"))
def csdn_sd(num):
    print("我发布的文章")
    for i in num:
        print(i)
        s=len(i)
        print(f"一共{s}篇文章")
csdn_sd(num=csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-right > div.navList-box > div.mainContent > div > div"))
print("*"*38,"我的基本信息","*"*38)
print("*"*38,"我的原力信息","*"*38)
def my_yuanli(number):
    print(f"我的原力等级:{number[0].get_text()}")
my_yuanli(csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-left > div > div.user-influence-list > ul > li > div.influence-top > div.influence-left > a > span"))
def my_yuanli_zong_fen(number):
    print(f"我的原力总分:{number}")
my_yuanli(number=csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-left > div > div.user-influence-list > ul > li > div.influence-bottom > div > span.influence-count"))
def my_yuanli_yue_fen(number):
    print(f"当月原理总分:{number[0].get_text()}")
my_yuanli_yue_fen(number=csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-left > div > div.user-influence-list > ul > li > div.influence-bottom > div > a > span.influence-count"))
print("*"*38,"我的原力信息","*"*38)
print("*"*38,"个人成就","*"*38)
def my_ge_ren_chengjiu_zan(num):
    print(f"当前活得总共:{num[0].get_text()}次赞")
my_ge_ren_chengjiu_zan(num=csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-left > div > div.user-achievement.user-profile-aside-common-box > div.aside-common-box-bottom > div > ul > li:nth-child(1) > div > span"))
def my_ge_ren_chengjiu_pinglun(num):
    print(f"总共获得了:{num[0].get_text()}次评论")
my_ge_ren_chengjiu_pinglun(num=csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-left > div > div.user-achievement.user-profile-aside-common-box > div.aside-common-box-bottom > div > ul > li:nth-child(2) > div > span"))
def my_ge_ren_chengjiu_shoucang(num):
    print(f"总共获得了:{num[0].get_text()}次收藏")
my_ge_ren_chengjiu_shoucang(num=csdn_x.select("#userSkin > div.user-profile-body > div > div.user-profile-body-left > div > div.user-achievement.user-profile-aside-common-box > div.aside-common-box-bottom > div > ul > li:nth-child(3) > div > span"))
print("*"*38,"个人成就","*"*38)
print("*"*38,"个人信息","*"*38)
def geren(names):
    print(f"{names[0].get_text()}")
geren(names=csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-b > p"))
def ip_phone(phone):
    print(f"IP归属地:{phone[0].get_text()}")
ip_phone(phone=csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-b > div.user-profile-head-address > span > span > span"))
def csdn_jiaru(times):
    print(f"加入csdn时间:{times[0].get_text()}")
csdn_jiaru(times=csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-b > div.user-profile-head-info-b-r > div > ul > li > span.user-general-info-key-word"))
def csdn_boke(names):
    print(f"博客简称:{names[0].get_text()}")
csdn_boke(names=csdn_x.select("#userSkin > div.user-profile-head > div.user-profile-head-info > div.user-profile-head-info-b > div.user-profile-head-info-b-r > div > div > div > h1"))
print("*"*38,"个人信息","*"*38)
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-11-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档