Z
Z
zdr2018-11-01 16:36:19
Python
zdr, 2018-11-01 16:36:19

Parsing in Python. beautifulsoup. Get the second element?

The html page has several tags:

<script>111</script>
<script>222</script>

When parsing
soup = BeautifulSoup(resp, features="html.parser")
print (soup.html.script)

gets the content of the first(111)
How to get the content of the second tag?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Segey K., 2018-11-01
@zdr

soup.find_all('script')
Get a list of elements

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question