I am trying to pull the election electoral votes to check when it updates. But the hard part is that all the classes change on every refresh. I want to search for the text Trump
and then find the next element which is the count.
I can find the element, by searching for the string Trump
:
import requests
import re
from bs4 import BeautifulSoup
url = "https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=who+is+winning+the+presidential+election&eob=enn/p//1/0///////////"
r = requests.get(url)
soup = BeautifulSoup(r.content)
elm = soup.find(text='Trump')
print elm.text
I found the Trump element, with lm = soup.find(text='Trump')
, but I don't know how to grab the next element after that one.