Answer the question
In order to leave comments, you need to log in
How to edit website code with python?
Hello. there is a need to change the data on the site for the screenshot. I want to try to do it by editing the element code on the page. Can you suggest libraries or other ways to implement this.
It is necessary: the script opens the site with some data, and at the output it gives a screen with other numerical data, which are generated according to special settings.
Answer the question
In order to leave comments, you need to log in
Easy to do with Selenium:
driver.get('http://lenta.ru')
driver.execute_script('''
var aTags = document.getElementsByTagName("a");
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].innerText.startsWith("07:50Опубликованы данные")) {
aTags[i].innerText = "Утки с Марса захватили вселенную!";
break;
}
}
''')
time.sleep(1)
screenshot = driver.get_screenshot_as_png()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question