hesapadim adlı üyeden alıntı: mesajı görüntüle
import requests
import os.path
from pathlib import Path
from bs4 import BeautifulSoup

filename = '/var/python/liste.txt'

if not os.path.exists(filename):
open(filename, 'w').close()

# Using readlines()
# file = open(filename, 'r')
# lines = file.readlines()

# count = 0
# Strips the newline character
# for line in lines:
# print("{}: {}" . format(count, line.strip()))
# count += 1

url = "https://www.asdfghgj.com"

html = requests.get(url).content
soup = BeautifulSoup(html, "html.parser")

# list = soup.find('div', class_="footer-middle").findAll('a')
count = 0
for a in soup.select('.footer-middle a'):
....ulkeUrl = a['href']
....ulkeAdi = a.get_text(strip = True)
....print(count, ':', ulkeUrl, '/', ulkeAdi)
....count += 1


ulkeler = input('ulke seciniz: ').replace(' ', '').split(',')

for ulkei in ulkeler:
....elm = soup.select('.footer-middle a')[ulkei]
....print(elm['href'])
r10'da tab yapamıyorum, 4 nokta = tab
Hocam bu şekilde çalıştırıp ekrana 1 yazdığımda hata kodu dönüyor.

Original exception was:
Traceback (most recent call last):
File "/var/python/testing.py", line 37, in <module>
elm = soup.select('.footer-middle a')[ulkei]
TypeError: list indices must be integers or slices, not str
Jufasto adlı üyeden alıntı: mesajı görüntüle
Her ülke için bir class oluştur ve her class'ın içerisine yapacağın işlemleri yaz. Daha sonrasında kullanıcıdan aldığın inputa göre if elif yapısıyla class'lara gönder.
Hocam o yapıyı hiç bilmiyorum ama örnek verebilirseniz incelemek isterim.