I'm trying to create an scraper which scrapes download links, I want to use regex but that would be a nightmare for me to do, I've found this library which is called BeautifulSoup, I'm trying to capture the urls in the children of div class="article-content" which is <p> tag, and this <h3> is the name of the urls,I don't want to combine all urls in one list but instead I used dictionary which is key is the name(<h3>) and value is the list of urls, enough of the talk here is the code.
import requests
from bs4 import BeautifulSoup
def scrape():
resp = requests.get('https://www.animeout.xyz/love-live-nijigasaki-gakuen-school-idol-doukoukai-1080p-300mb720p-150mbepisode-1/')
soup = BeautifulSoup(resp.text,'html.parser')
contents = soup.find('div',class_='article-content')
output = {}
for tag in contents.children:
if tag.name == 'h3':
name = tag.text
links = []
for sibling in tag.next_siblings:
if sibling.name == 'p':
for link in sibling.find_all('a',text='Direct Download'):
links.append(link.get('href'))
if sibling.name == 'h3':
output.update({name:links})
break
so far I only managed to capture only 1 key, is there a pythonic way to do this?