Using this page as an example:
https://quizlet.com/229413256/chapter-6-configuring-networking-flash-cards/
How would one hypothetically scrape the text answer from behind the flashcard? It's hidden right now, but when you click on it, it rotates and shows the answer.
What I've seen so far looks like this, but the right element isn't being selected I'm sure:
def find_quizlet_flashcard_answer(quizlet_url):
# desktop user-agent
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0"
# mobile user-agent
MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36"
headers = {"user-agent": USER_AGENT}
resp = requests.get(quizlet_url, headers=headers)
if resp.status_code == 200:
soup = BeautifulSoup(resp.content, "html.parser")
inner_divs = soup.find_all("div", {"aria-hidden": "true"})
for g in inner_divs:
result = g.text
print(result)
return result