Answer the question
In order to leave comments, you need to log in
How to display code with browser extension?
There is a site and a browser extension to it, which adds its own block (div) to the site's HTML. I decided to parse this site in python. Having found nothing in the requests + bs4 functionality for working with extensions, I decided to parse using seleniuma. I connected the extension to the browser, but when receiving HTML, the program displays the source code, and not the code of the page with changes (browser extension), although the extension is displayed in the browser. Here is the code:
from selenium import webdriver
import os
from selenium.webdriver.chrome.options import Options
headers = {'user-agent':'*', 'accept':'*'}
executable_path = "chromedriver.exe"
os.environ["webdriver.chrome.driver"] = executable_path
chrome_options = Options()
chrome_options.add_extension('1.crx') #расширение
driver = webdriver.Chrome(executable_path=executable_path, options=chrome_options)
driver.get("*url*")
html = driver.page_source
print(html)
Answer the question
In order to leave comments, you need to log in
You can still use requests, given that most of the messages that appear appear in XHR, I will add an example instruction later.
1) First, open the element's code, go to the Network, and in XHR, the loaded text is mainly displayed there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question