Advertisement
Acer1968

TypeError with find_element_by_id from BeautifulSoap

Sep 3rd, 2020
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from bs4 import BeautifulSoup as BS
  2.  
  3. html="""
  4. <html>
  5.  
  6.  <head>
  7.  </head>
  8.  
  9.  <body>
  10.    <h1 id="heading">This is H1 with id = heading</h1>
  11.  </body>
  12.  
  13. </html>
  14. """
  15.  
  16. soup = BS(html,"html.parser")
  17. print(soup.find_all("h1")[0].text) # Output: This is H1 with id = heading
  18. print(soup.find_element_by_id("heading")) # TypeError: 'NoneType' object is not callable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement