Abdiaziz Ahmed 3L4G
Abdiaziz Ahmed 3L4G

Reputation: 27

Scraping hidden jquery values using python

HERE is the site I believe its hosted on GitHub.

I am having trouble scraping the values in the input fields. Specifically private key and Public. I tried using Selenium and BeautifulSoup but it would give empty values, rather None (the HTML doesn't contain the keys).

I checked the page source and it seems that the input value is empty (not contained within the HTML) but when you load the page it is visible and existent in the input box.

Here is my code:

def openit(browser):

    browser.get('file:///Users/Aha/Desktop/Code/english/index.html')
    time.sleep(5)
    nav = browser.find_element_by_id("addr")

    print(nav.text)
    return browser.page_source

soupdata = openit(browser)
soup = BeautifulSoup(soupdata, 'html.parser')
val = soup.find('input', {'id': 'addr'}).get('value')
print (val)

Upvotes: 2

Views: 384

Answers (1)

drec4s
drec4s

Reputation: 8077

You can retrieve that value via execute_script method of the selenium webdriver

print(browser.execute_script("return $('#addr').val();"))

Output:

14ropRunS5iY9sx9d9mpCRNEsXj7RtTtuS

Upvotes: 1

Related Questions