python 爬取csdn我的个人信息

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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值