Python
- 39 ответов
- 0 вопросов
18
Вклад в тег
def create_map():
global obstacles
locations = []
for i in range(10):
row = random.randint(0, 9)
col = random.randint(0, 9)
location = [col * 64 + 20, row * 64 + 20 + 640]
if not (location in locations):
locations.append(location)
type = random.choice(["tree", "flag"])
if type == "tree": img = "skier_tree.png"
elif type == "flag": img = "skier_flag.png"
obstacle = ObstacleClass(img, location, type)
obstacles.add(obstacle)
from bs4 import BeautifulSoup
html = '<a class="bttn_green" href="/index.php?r=quests/reward&id=74538347&quest_id=1598044167">text</a> \
<a class="bttn_green" href="/index.php?r=quests/reward&id=74498540&quest_id=1597875696">text</a> \
<a class="bttn_green" href="/index.php?r=quests/reward&id=74205167&quest_id=1596578514">text</a> \
<a class="bttn_green" href="/index.php?r=quests/reward&id=74479806&quest_id=1597790754">text</a> \
<a class="bttn_green" href="/index.php?r=quests/reward&id=74327918&quest_id=1597093800">text</a>'
soup = BeautifulSoup(html)
links = soup.findAll("a", {"class": "bttn_green"})
for link in links:
# print(link.get_text())
print(link.attrs["href"])