0

On: http://arithmetic.zetamac.com/game?key=96823302, we need to take the problem out of the problem tag in the <span> class.

It is constantly updated, how can I retrieve the data out each time using BeautifulSoup/Python?

I know it will be like:

from bs4 import BeautifulSoup
soup = BeautifulSoup(requests.get("http://arithmetic.zetamac.com/game?key=96823302").content)
problem = soup.find("span",class_="problem") #Initial finding

a = True
while(a == True):
  print problem
  problem = soup.find("span",class_="problem")

//Then it will re-loop

But this only prints out: <span class="problem"></span> not the inside like 2 + 2 or 2 x 2

Savir
  • 17,568
  • 15
  • 82
  • 136
Gaandmit
  • 53
  • 3
  • 2
    problem generated at runtime by javascript use `selenium` package [here](http://selenium-python.readthedocs.io/) – Hisham Karam Oct 25 '16 at 05:36
  • So like: content = driver.find_element_by_class_name('problem')?? But this wont parse the text though – Gaandmit Oct 25 '16 at 05:48
  • http://stackoverflow.com/questions/10426321/best-practice-to-wait-for-a-change-with-selenium-webdriver – Joran Beasley Oct 25 '16 at 05:51
  • although you can probably just wait for a few seconds for a non existant div and then try and get the contents of the problem span ... it should take almost no time for the js to populate the problem... see also http://www.software-testing-tutorials-automation.com/2014/01/webdriver-wait-for-text-to-be-present.html – Joran Beasley Oct 25 '16 at 05:54

0 Answers0