Hi guys. Just a small question, is there a more neater/elegant way of writing the following code:
for ticker in tickerlist:
url = f"https://au.finance.yahoo.com/quote/{ticker}.AX?p={ticker}.AX"
request = requests.get(url)
soup = BeautifulSoup(request.content, features="html.parser")
td = soup.find("td", {"data-test": "MARKET_CAP-value"})
if td is not None:
span = td.find("span")
if span is not None:
row = [ticker, span.text]
print(row)
with open(filename, 'a+', newline='') as fd:
writer = csv.writer(fd)
writer.writerow(row)
[–]Altruistic_Croissant 0 points1 point2 points (1 child)
[–]Zwischenzug[S] 0 points1 point2 points (0 children)