How to extract the contents between these tags when they're on multiple/ different lines?
<link>
https://widget.websta.me/rss/n/bleh
</link>
I tried: content = findall('(.*)', web_page_contents, re.DOTALL) But I get the next mention of instead of this one^
You can use BeautifulSoup
to do that. It has a very good documentation and is very easy.
The following code will work:
import requests
from bs4 import BeautifulSoup
r = requests.get(webpage_url)
soup = BeautifulSoup(r.content, 'lxml')
for link in soup.find_all('link'):
print link.text
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.