Skip to content

Commit a2817ab

Browse files
committed
Update an example
1 parent 13c63fc commit a2817ab

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

examples/cdp_mode/raw_socialblade.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,25 @@
88
sb.uc_gui_click_captcha()
99
sb.sleep(0.5)
1010
channel_name = "michaelmintz"
11-
sb.cdp.press_keys('input[name="query"]', channel_name)
12-
sb.cdp.click('form[action*="/search"] button')
13-
sb.sleep(2)
14-
sb.cdp.click('a[title="%s"] h2' % channel_name)
11+
channel_title = "Michael Mintz"
12+
sb.cdp.press_keys('input[placeholder*="Search"]', channel_name)
1513
sb.sleep(1.5)
14+
sb.cdp.click('a:contains("%s")' % channel_title)
15+
sb.sleep(2)
1616
sb.cdp.remove_elements("#lngtd-top-sticky")
1717
sb.sleep(1.5)
1818
name = sb.cdp.get_text("h1")
19-
link = sb.cdp.get_attribute("#YouTubeUserTopInfoBlockTop h4 a", "href")
20-
subscribers = sb.cdp.get_text("#youtube-stats-header-subs")
21-
video_views = sb.cdp.get_text("#youtube-stats-header-views")
22-
rankings = sb.cdp.get_text(
23-
'#socialblade-user-content [style*="border-bottom"]'
24-
).replace("\xa0", "").replace(" ", " ").replace(" ", " ")
19+
source = sb.get_page_source()
20+
base = "https://www.youtube.com/c/"
21+
base2 = 'href="/youtube/c/'
22+
start = source.find(base2) + len(base2)
23+
end = source.find('"', start)
24+
link = base + source[start:end]
2525
print("********** SocialBlade Stats for %s: **********" % name)
2626
print(">>> (Link: %s) <<<" % link)
27-
print("* YouTube Subscribers: %s" % subscribers)
28-
print("* YouTube Video Views: %s" % video_views)
27+
print(sb.get_text('[class*="grid lg:hidden"]'))
2928
print("********** SocialBlade Ranks: **********")
30-
for row in rankings.split("\n"):
31-
if len(row.strip()) > 8:
32-
print("--> " + row.strip())
29+
print(sb.get_text('[class*="gap-3 flex-1"]'))
3330
for i in range(17):
3431
sb.cdp.scroll_down(6)
3532
sb.sleep(0.1)

0 commit comments

Comments
 (0)