There is a code

<div id="post-20629724_1128951" class="_post post page_block deep_active" data-post-id="-20629724_1128951" onclick="wall.postClick('-20629724_1128951', event);" post_view_hash="d6b48097f9db5c778b"> <div class="_post_content"> 

and XPATH request to it //*[@id="post-20629724_1128951"]

The question is what should be added to the request in order for the selenium to pull the attribute value out of the code (I might be wrong in the terminology) id, that is, to post-20629724_1128951

    1 answer 1

     item.find_element_by_xpath('//*[@id="post-20629724_1128951"]').get_attribute("data-post-id") 
    • Thank you very much! It all started. Before that, I had been looking for 3 hours for the info about how to pull out the attribute value, but I did not find anything other than adding a "dog" to the request. Good to you :) - terequell
    • If my answer has helped you, then tick his answer (the check mark on the left of my answer should turn green) - danilshik