伙计们,我想要追随者Instagram的复制昵称。
这是我的代码,但不起作用:
browser = webdriver.Chrome('./chromedriver')
"GO INSTAGRAM PAGE FOR LOGIN"
browser.get('https://www.instagram.com/accounts/login/?hl=it')
sleep(2)
"ID AND PASSWORD"
elem = browser.find_element_by_name("username").send_keys('test')
elem = browser.find_element_by_name("password").send_keys('pswtest')
"CLICK BUTTON AND OPEN INSTAGRAM"
sleep(5)
good_elem = browser.find_element_by_xpath('//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/span/button').click()
sleep(5)
browser.get("https://www.instagram.com")
sleep(2)
browser.get("https://www.instagram.com/test/")
sleep(10)
copy = browser.find_element_by_class_name('FPmhX notranslate zsYNt').Text
这是Instagram:
"
a class="FPmhX notranslate zsYNt " title="s_yagami_" href="/s_yagami_/">s_yagami_ a"
我想复制标题,帮帮我。
title
是<a>
标签的属性,所以可以尝试:
copy = browser.find_element_by_class_name('FPmhX notranslate zsYNt')
copy.get_attribute("title")