I'm trying to parse html page and get the value from a textarea, but i can't achieve it, i will put my code (i started with selenium but it didn't work either). I don't really understand where this value is in the DOM
so the value is in the inspector but not in the html code... I can't find a way to get it. Please can someone explain me ? Thanks !
#coding: utf8
import lxml.html as lh
import urllib.request
nb = 36893488147419103232
#x=0
#GRAB
#while x<=1: #A changer en fonction du nb de pages à crawl
url_base="https://bitcoin.oni.su/"+str(nb)#+x)
req = urllib.request.Request(url_base, headers={'User-Agent': 'Mozilla/5.0'})
doc=lh.parse(urllib.request.urlopen(req))
get_btc_adr = doc.xpath('//textarea[@id="BTCaddrC"]')
print(get_btc_adr, get_btc_adr[0].value)#Tried Value, text, element_Text()....
#x+=1
After looking around and not giving up, i finally made it, here's the working code in case someone encounters same situation :
#coding: utf8
from selenium import webdriver
nb = 36893488147419103232
x=0
driver = webdriver.Firefox()
#GRAB
while x<=1: #A changer en fonction du nb de pages à crawl
url_base="https://bitcoin.oni.su/"+str(nb+x)
driver.get(url_base)
btc_adr = driver.execute_script("return document.getElementById('BTCaddrC').value")
with open("result.txt","a") as f:
f.write(str(nb+x)+" "+btc_adr+"\n")
print(str(nb+x),btc_adr)
x+=1
Thanks for all trying to help !