How do I access content in a script tag using bs4
I'm trying to use beautiful soup to find a script tag on a page that has the dataLayer and then retrieve the value of postNo and print it. <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <!-- Data Layer - Begin --> <script> dataLayer = [ { 'country': 'UnitedKingdom', 'site': 'Blog', 'postNo': '34', 'pageType': 'Home', 'pageType2': 'Blog', 'pageType3': 'Top Tips' } ]; </script> <!-- Data Layer - End --> </head>
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.