Search code examples
pythonhtmlbeautifulsouphtml-parsing

How to get data from span tag which have custom characteristics? (BeautifulSoup)


I have following span tag. How can I scrape xuRMlBoIUcI7nAJktBcJvPByp1DLE4aPGzq3JNiRKsdNqUkVSJBY%2BggxRhp0GcRx4Gw4lWQxbTk%3D which is assigned to data-slug?

    <span data-ju-jspjrvxy="" 
    data-slug="xuRMlBoIUcI7nAJktBcJvPByp1DLE4aPGzq3JNiRKsdNqUkVSJBY%2BggxRhp0GcRx4Gw4lWQxbTk%3D" 
    data-gtm-clickedelement="CTA button" data-gtm-offer="" data-ju-wvxjoly-pk="303795"
 data-gtm-voucher-id="303795" class="businessinsiderus-voucher-button-holder clear">

        

Solution

  • If my understanding of your problem is correct you want to scrape an attribute of a tag. If this is in fact your problem the following link will provide a solution: Extracting an attribute value with beautifulsoup