So I was deleting empty indexes in my list
of
['','','','','A','B','C','','']
I used
list.pop[0]
list.pop[1]
list.pop[2]
list.pop[3]
list.pop[-1]
list.pop[-2]
in order to remove the empty objects.
But it does not delete the first 2 items and skips to [A] at list.pop[3]
, deleting data when it is not my intention to do so.
What's wrong and how can I get around this? Sorry for the non-Pythonic code.
Here's the exact code I used.
import requests, re
from bs4 import BeautifulSoup
url='https://bn.mappersguild.com/'
headers={"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'}
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
osurow = soup.find('td', string='osu')
osu = osurow.find_parent("table", {"class": "table table-sm table-dark table-hover col-6 col-md-3"})
osutext = osu.get_text()
osu = osu.find_all('a')
osuname = osutext.split('\n')
osuname.remove('osu')
osuname.pop(0)
osuname.pop(1)
osuname.pop(2)
osuname.pop(3) #Here's the point where it deletes - Mo -
osuname.pop(-1)
osuname.pop(-2)
osuname.pop(-3) #Here's the point where it deletes Zelq
print ('osu!standard profile listing')
for element in osu:
print(element)
print(osuname)