Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- url = "https://artifact.gamepedia.com/Cards"
- r = requests.get(url)
- data = r.text
- soup = BeautifulSoup(data, "lxml")
- numbers = 310
- cards = False
- names = []
- names_to_links = []
- for link in soup.find_all('a'):
- if link.get('title') == 'Axe':
- cards = True
- if cards:
- names.append(link['title'])
- names_to_links.append({
- "name": link['title'],
- "href": link['href']
- })
- numbers -= 1
- if numbers < 1:
- cards = False
- images = []
- for img in soup.find_all('img'):
- for n in names:
- if img.get('alt') and n in img.get('alt'):
- images.append({
- "name": n,
- "srcset": img.get('srcset'),
- "src": img.get('src')
- })
- print(names)
- print(names_to_links)
- print(images)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement