简体   繁体   中英

Reading specific range of lines in html in python

May I check with you, is there any function in beautifulsoup that can allow me to read a specific range of line from the HTML code and print it?

No, why? BeautifulSoup is a parser. It parses your HTML that you already have in a variable. When you have it in a variable, say html , selecting a range of lines is trivial:

print(html.splitlines()[startline:endline])

and does not require parsing anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM