我試圖從圖片類profile_view_img_5087188獲取所有圖片,但在頁面源代碼中有多個類「profile_view_img_xxxxxx」,並且它們包含的圖片的相同網址的數量較少包括圖像按類別獲取圖片並使用Selenium Python進行點擊
http://i.imgur.com/oraB49H.png
類,我想如果點擊上面的圖片網址找到
<head><style type="text/css">.profile_view_img_5087188 { background-image: url('http://i.imgur.com/oraB49H.png'); }</style></head>
<a class="cursor earn_pages_button profile_view_img_5087188" onclick="startlink52efa('newlookskincenter','follow','99218',16837);imageWin('http://instagram.com/newlookskincenter','Instagram','99218','newlookskincenter','qFVnV5xlY2OJaW4','1015','500','follow',16837)"></a>
這裏是我的代碼,但不工作
like_button = browser.find_elements_by_css_selector("div > span > a")
for links in like_button:
if "http://i.imgur.com/oraB49H.png" in link.get_attribute('href'):
links.click()
我沒有看到在上面提供任何標籤'href'屬性,你可以添加一些更多的HTML,這有助於澄清更多 – NarendraR
圖像源是在樣式表
– Bostan