From a2817abcd8f02c191f5318c275a5094df2dac173 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sat, 29 Mar 2025 11:45:50 -0400 Subject: [PATCH] Update an example --- examples/cdp_mode/raw_socialblade.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/examples/cdp_mode/raw_socialblade.py b/examples/cdp_mode/raw_socialblade.py index fde723e6..8afbcf6b 100644 --- a/examples/cdp_mode/raw_socialblade.py +++ b/examples/cdp_mode/raw_socialblade.py @@ -8,28 +8,25 @@ with SB(uc=True, test=True, ad_block=True, pls="none") as sb: sb.uc_gui_click_captcha() sb.sleep(0.5) channel_name = "michaelmintz" - sb.cdp.press_keys('input[name="query"]', channel_name) - sb.cdp.click('form[action*="/search"] button') - sb.sleep(2) - sb.cdp.click('a[title="%s"] h2' % channel_name) + channel_title = "Michael Mintz" + sb.cdp.press_keys('input[placeholder*="Search"]', channel_name) sb.sleep(1.5) + sb.cdp.click('a:contains("%s")' % channel_title) + sb.sleep(2) sb.cdp.remove_elements("#lngtd-top-sticky") sb.sleep(1.5) name = sb.cdp.get_text("h1") - link = sb.cdp.get_attribute("#YouTubeUserTopInfoBlockTop h4 a", "href") - subscribers = sb.cdp.get_text("#youtube-stats-header-subs") - video_views = sb.cdp.get_text("#youtube-stats-header-views") - rankings = sb.cdp.get_text( - '#socialblade-user-content [style*="border-bottom"]' - ).replace("\xa0", "").replace(" ", " ").replace(" ", " ") + source = sb.get_page_source() + base = "https://www.youtube.com/c/" + base2 = 'href="/youtube/c/' + start = source.find(base2) + len(base2) + end = source.find('"', start) + link = base + source[start:end] print("********** SocialBlade Stats for %s: **********" % name) print(">>> (Link: %s) <<<" % link) - print("* YouTube Subscribers: %s" % subscribers) - print("* YouTube Video Views: %s" % video_views) + print(sb.get_text('[class*="grid lg:hidden"]')) print("********** SocialBlade Ranks: **********") - for row in rankings.split("\n"): - if len(row.strip()) > 8: - print("--> " + row.strip()) + print(sb.get_text('[class*="gap-3 flex-1"]')) for i in range(17): sb.cdp.scroll_down(6) sb.sleep(0.1)