Reputation: 131
I searched a lot how to solve this problem but I didn't find anything I could make it work. Basically I have this webpage:
http://databank.worldbank.org/data/embed-int/Table-1-SDDS-new/id/4f2f0c86
and what I'm trying to do is change the country with Python in order to extract the data from the HTML (I already know how to extract the data). Point is, I don't know how to change the country. Could you help me with that?
I saw many solutions that were similar but, probably due to my lack of experience with HTML, I didn't understand them well.
Thank you in advance.
Upvotes: 0
Views: 284
Reputation: 84465
You are better off using a method like selenium. In that case you can click the dropdown and use the inputbox to send your country of interest and then enter.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
d = webdriver.Chrome()
d.get("http://databank.worldbank.org/data/embed-int/Table-1-SDDS-new/id/4f2f0c86")
dropdown = WebDriverWait(d,10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".chosen-single")))
dropdown.click()
input = d.find_element_by_css_selector('.chosen-search input')
input.send_keys('Brazil')
input.send_keys(Keys.RETURN)
Upvotes: 1
Reputation: 31
I don't know how to select option from drop-down menu too, but here is worldbank api
Upvotes: 0