Ich habe this site. Ich möchte die Symbole extrahieren, die unter dem Titel des Artikels erscheinen (EXAS, ESNT, ENZ, CENT, AEE). Ich bin ein Anfänger, so habe ich versucht, einen eher anti-pythonic Ansatz:Extrahieren zwischen Teilstring von zwei Strings in einer Website
import requests
link="https://www.zacks.com/commentary/99386/new-strong-buy-stocks-for-december-29th"
fetch_data = requests.get(link)
content = str((fetch_data.content))
# I know that in the source code the symbols appear between "tickers" and "publish_date" therefore:
tickers= "tickers :"
pd = "publish_date :"
Z= ("%s(.*)%s" % (tickers,pd))
result = re.search(Z, content)
print (result)
# Just printing out the substring between tickers and pd
Output: <_sre.SRE_Match object; span=(95142, 95213), match="tickers : [\\'EXAS\\',\\'ESNT\\',\\'ENZ\\',\\'CEN>
Wie kann ich nur die Symbole ausdrucken? Auch das letzte Symbol 'CEN' sollte ausgedruckt werden, da 'CENT' und 'AEE' ebenfalls fehlen.
"tickers : [\\'EXAS\\',\\'ESNT\\',\\'ENZ\\',\\'CENT\\',\\'AEE\\]