why I can't use findall()method in this code and what is the solution

Question:

In the code below it works correct until findall. How can I solve this? The main purpose of this code to receive the data stored in this site and this link contain xml data but I am trying to get the data asif from beautifulsoup and treat it as html file.
I know anther solution but I need to try this.

traceback error warnings.warn( Traceback (most recent call last):
File "D:programvenvtry.py", line 10, in
datas=dp.findall(‘comment’) File
"C:UsersAbdullahAppDataLocalProgramsPythonPython310libxmletreeElementTree.py",
line 669, in findall return self._root.findall(path, namespaces)

TypeError: ‘NoneType’ object is not callable

from bs4 import BeautifulSoup
import urllib.request,urllib.error,urllib.parse
import re;import lxml
import xml.etree.ElementTree as ET
count =0
html=urllib.request.urlopen('http://py4e-data.dr-chuck.net/comments_1591221.xml').read()
url=BeautifulSoup(html,'html.parser')
dp=ET.ElementTree(url)
datas=dp.findall('comment')
Asked By: Abdallah Faik

||

Answers:

import requests
from bs4 import BeautifulSoup

url='http://py4e-data.dr-chuck.net/comments_1591221.xml'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')

comments = soup.select('comment')
print(comments)

Resulting in a list with all comment tags:

[<comment>
<name>Ajay</name>
<count>99</count>
</comment>, <comment>
<name>Sheonagh</name>
<count>99</count>
</comment>,...]
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.